简体   繁体   中英

No such module psutil, even though psutil is installed

I am on OS X El Capitan.

I want to import psutil for a python script, but get module psutil not found .

If I do pip install psutil I get psutil already installed.

How is this possible that I have psutil installed, but it does not find it in the script?

I am using both macports and homebrew to install several python packages. Maybe this is a problem?

Any ideas how I can get psutil to import?

I have python27 and python34 on my system. For this project I need to use python27.

This is my log for pip freeze

altgraph==0.10.2
bdist-mpkg==0.5.0
bonjour-py==0.3
chardet==2.3.0
git-remote-helpers==0.1.0
macholib==1.5.1
matplotlib==1.3.1
modulegraph==0.10.4
numpy==1.8.0rc1
PocketSphinx==0.8
psutil==4.0.0
py2app==0.7.3
PyAudio==0.2.9
pygal==2.1.1
pyobjc-core==2.5.1
pyobjc-framework-Accounts==2.5.1
pyobjc-framework-AddressBook==2.5.1
pyobjc-framework-AppleScriptKit==2.5.1
pyobjc-framework-AppleScriptObjC==2.5.1
pyobjc-framework-Automator==2.5.1
pyobjc-framework-CFNetwork==2.5.1
pyobjc-framework-Cocoa==2.5.1
pyobjc-framework-Collaboration==2.5.1
pyobjc-framework-CoreData==2.5.1
pyobjc-framework-CoreLocation==2.5.1
pyobjc-framework-CoreText==2.5.1
pyobjc-framework-DictionaryServices==2.5.1
pyobjc-framework-EventKit==2.5.1
pyobjc-framework-ExceptionHandling==2.5.1
pyobjc-framework-FSEvents==2.5.1
pyobjc-framework-InputMethodKit==2.5.1
pyobjc-framework-InstallerPlugins==2.5.1
pyobjc-framework-InstantMessage==2.5.1
pyobjc-framework-LatentSemanticMapping==2.5.1
pyobjc-framework-LaunchServices==2.5.1
pyobjc-framework-Message==2.5.1
pyobjc-framework-OpenDirectory==2.5.1
pyobjc-framework-PreferencePanes==2.5.1
pyobjc-framework-PubSub==2.5.1
pyobjc-framework-QTKit==2.5.1
pyobjc-framework-Quartz==2.5.1
pyobjc-framework-ScreenSaver==2.5.1
pyobjc-framework-ScriptingBridge==2.5.1
pyobjc-framework-SearchKit==2.5.1
pyobjc-framework-ServiceManagement==2.5.1
pyobjc-framework-Social==2.5.1
pyobjc-framework-SyncServices==2.5.1
pyobjc-framework-SystemConfiguration==2.5.1
pyobjc-framework-WebKit==2.5.1
pyOpenSSL==0.13.1
pyparsing==2.0.1
python-dateutil==1.5
pytz==2013.7
scipy==0.13.0b1
six==1.4.1
SphinxBase==0.8
vboxapi==1.0
wheel==0.26.0
xattr==0.6.4
zope.interface==4.1.1

I was unable to reproduce your problem in a virtualenv, below are the steps I used.

Desktop   $ virtualenv -p python2.7 virtenv
Desktop   $ cd virtenv
virtenv   $ source bin/activate
(virtenv) $ sudo pip install psutil
(virtenv) $ python
(virtenv) > import psutil
(virtenv) > exit()
(virtenv) $ deactivate

You could try removing it and reinstalling it.

Just tried to run glances, some kind of diagnostic tool that requires psutil aswell. Unfortunatelly got an error :

PsUtil module not found. Glances cannot start.

Ran pip freeze, saw that i had it installed and i decided to remove and try to reinstall. Uninstalled (Successfully uninstalled psutil-5.0.1) and when tried again to install psutil-5.0.1 failed. Ran again pip freeze and noticed there is a minor version (psutil==2.2.1) that is served in case you remove the latest (very strange). Anyway, run again pip uninstall psutil, removed that minor version and when i tried again to reinstall worked correctly, installing the last version.

Now everything works ok.

LE: Python 2.7.5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM