I tried running the following python code in Eclipse on Windows but it is showing errors saying pwd is not a valid import:
import os
import pwd
import socket
pinfo=pwd.getpwuid(os.getuid())
Can I use if not win32 to bypass this part so when it runs on Windows it just jumps at and doesn't create an error?
if not win32:
import os
import pwd
import socket
pinfo=pwd.getpwuid(os.getuid())
else:
return
If yes, what do I need to do to use this win32 since it's also showing an error saying undefined variable?
You should use sys.platform for that.
if sys.platform != 'win32':
...
if sys.platform != 'win32':
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With