#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    40
    Rep Power
    10

    Issue using 3rd party package in a script


    Hello,

    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:

    Code:
      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
    In the psutil sub-directory there are the following files:
    Code:
    error.py
    _common.py
    _compat.py
    _error.py
    _psbsd.py
    _pslinux.py
    _psmswindows.py
    _psosx.py
    _psposix.py
    __init__.py
    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.
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    605
    Rep Power
    65
    Strange, I have no problems with pyutil installed on Windows7 for either Python27 or Python33.

    From http://code.google.com/p/psutil/
    download Windows installer
    psutil-0.7.0.win32-py2.7.exe
    or
    psutil-0.7.0.win32-py3.3.exe

    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
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    40
    Rep Power
    10
    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:
    Code:
    ['', 'C:\\Python33\\Lib\\idlelib', 'C:\\Windows\\system32\\python33.zip', 'C:\\Python33\\DLLs', 'C:\\Python33\\lib', 'C:\\Python33', 'C:\\Python33\\lib\\site-packages']
    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.
    Last edited by MODDOM; June 14th, 2013 at 12:34 PM.

IMN logo majestic logo threadwatch logo seochat tools logo