June 14th, 2013, 05:22 AM
Issue using 3rd party package in a script
I've come across what I thought was a simple problem to solve and perhaps it is, but I need some help solving it.
I want to use a package I downloaded called 'psutil'. Maybe someone has experience using it. Anyway, I installed the package and I can use it without problems in the Python shell but when I tried using it in a script it said no module psutil existed. I then but the psutil folder from the lib\site-packages folder in the same directory as my .py file and now I get a different error:
In the psutil sub-directory there are the following files:
File "C:\Users\Dominic\Documents\programs\psutil\__init__.py", line 77, in <module> import psutil._psmswindows as _psplatform
File "C:\Users\Dominic\Documents\programs\psutil\_psmswindows.py", line 15, in <module> import _psutil_mswindows
ImportError: No module named _psutil_mswindows
Basically I don't know what I'm suppose to do to solve this error. There seems to be at least 1 file missing. How come the module works fine through the shell but not through a script?
My experience installing and using 3rd party packages in python is very limited and any information (even if isn't directly related to this problem) would be useful.
June 14th, 2013, 10:31 AM
Strange, I have no problems with pyutil installed on Windows7 for either Python27 or Python33.
download Windows installer
Let's hope you didn't save your own script file as pyutil.py
Last edited by Dietrich; June 14th, 2013 at 10:39 AM.
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25
June 14th, 2013, 12:29 PM
I used exactly the links you quoted. Downloaded the install exe for Python version 3.3. There were no problems in the installation but this is still a problem. I think it is very strange how I can put the command 'import psutil' into the shell and everything works, but when I write a script with it in, suddenly it is a problem?!?!
I think this problem also exists with other 3rd party packages on my system, not just psutil. This would imply that the issue is definitely my system. Using the python shell I used sys.path to check the search path directories, this is what came up:
So everything seems normal there and the lib\site-packages folder is definitely being seen. I read something online about another path variable 'PYTHONPATH'. Don't know much about it though.
['', 'C:\\Python33\\Lib\\idlelib', 'C:\\Windows\\system32\\python33.zip', 'C:\\Python33\\DLLs', 'C:\\Python33\\lib', 'C:\\Python33', 'C:\\Python33\\lib\\site-packages']
Last edited by MODDOM; June 14th, 2013 at 12:34 PM.