No such module psutil, even though psutil is installed

亡梦爱人 提交于 2020-05-14 13:00:06

问题


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

回答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.




回答2:


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



来源:https://stackoverflow.com/questions/35621808/no-such-module-psutil-even-though-psutil-is-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!