当我在 python 中检查 psutil 的版本时,它说我有版本0.5.0
:
$ uname -a
Linux mypc 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux
$ python
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> psutil.__version__
'0.5.0'
>>> psutil.virtual_memory()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'virtual_memory'
>>> psutil.__file__
'/usr/lib/pymodules/python2.7/psutil/__init__.pyc'
我想升级到具有以下virtual_memory()
方法的更新版本的 psutil:
$ sudo pip install 'psutil==2.2.1' --upgrade
Requirement already up-to-date: psutil==2.2.1 in /usr/local/lib/python2.7/dist-packages
Cleaning up...
同一个包的两个不同路径意味着psutil
安装了两次:
/usr/local/lib/python2.7/dist-packages
/usr/lib/pymodules/python2.7/psutil/__init__.pyc
我只想要psutil
版本2.2.1
。清理其他不需要的0.5.0
包并只保留以后的包的最佳方法是什么?
根据评论 - 检查是否通过以下任一路径安装dpkg
:
$ dpkg -S /usr/local/lib/python2.7/dist-packages
dpkg-query: no path found matching pattern /usr/local/lib/python2.7/dist-packages
$ dpkg -S /usr/lib/pymodules/python2.7/psutil/__init__.pyc
dpkg-query: no path found matching pattern /usr/lib/pymodules/python2.7/psutil/__init__.pyc