Reputation: 13416
I've just installed WinPython (32 bit) on my Windows machine and am trying to run code which otherwise works on my remote linux machine. The code makes use of Python's platform
library. The problem is when I run my code, I get an error where my code is trying to make use of platform
library's function platform.system()
platform.system()
should return a string like Linux
, Windows
, etc., but on my Windows system, a call to platform.system()
gets the following result:
>>> import platform
>>> print platform.system()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'system'
Any ideas why the above is happening ? The WinPython I have is based on the latest Python 2.7 (I think 2.7.10), and Python 2.7 DOES have a platform.system()
method as mentioned here: https://docs.python.org/2/library/platform.html
So I'm not sure what's the problem. Any ideas ?
Upvotes: 1
Views: 3639
Reputation: 1
When I ran the code, it said that "platform" was a string, which it wasn't. I just did import platform as platform_module
instead of import platform
and then replaced "platform" with "platform_module" and it worked.
Upvotes: 0
Reputation: 19362
It definitely looks like the platform
you get when you import platform
is not the built-in module. You should find out what exactly is imported.
I believe the folowing should print out find all candidates. What does it print in your case?
import os, sys
for p in sys.path:
try:
for fn in (os.listdir(p or '.')):
if 'platform' in fn.lower():
print os.path.join(p, fn)
except OSError:
print ':skipped', p
Upvotes: 3
Reputation: 1191
This has been tried on winpython2.7.10 32 bit:
import platform;platform.system()
Upvotes: 3