使用pip安装时出现属性错误 [英] Attribute Error Installing with pip
问题描述
这是一个头昏眼花,所以我在阅读并阅读了有关此问题的所有先前文章之后,发布了此问题.
This is a head stumper so I am posting this question AFTER having examined and read all of the prior posts on this issue.
运行OSX 10.9 Python 2.7无virtualenv
Running OSX 10.9 Python 2.7 no virtualenv
pip install awssh
Downloading/unpacking awssh
Downloading awssh-0.1.tar.gz
Cleaning up...
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/basecommand.py",
line 122, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/commands/install.py",
line 274, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/req.py",
line 1215, in prepare_files
req_to_install.run_egg_info()
File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/req.py",
line 288, in run_egg_info
logger.notify('Running setup.py (path:%s) egg_info for package %s' % (self.setup_py, self.name))
File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/req.py",
line 265, in setup_py
import setuptools
File "/Library/Python/2.7/site-packages/setuptools/__init__.py", line 11, in <module>
from setuptools.extension import Extension
File "/Library/Python/2.7/site-packages/setuptools/extension.py", line 8, in <module>
File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 21, in <module>
packaging = pkg_resources.packaging
AttributeError: 'module' object has no attribute 'packaging'
推荐答案
此错误是由pkg_resources
的过时版本引起的.为了摆脱该错误,请执行以下操作:
This error is caused by the presence of an outdated version of pkg_resources
. In order to get rid of the error, do the following:
-
启动python会话,导入
pkg_resources
,并查看从中加载文件的文件:
Start a python session, import
pkg_resources
, and view the file from which it is loaded:
In [1]: import pkg_resources
In [2]: pkg_resources.__file__
Out[2]: '/usr/lib/python2.7/dist-packages/pkg_resources.pyc'
删除此文件(和关联的*.py
文件):
Remove this file (and the associated *.py
file):
$ sudo rm /usr/lib/python2.7/dist-packages/pkg_resources.py*
就是这样!重新运行安装;它应该完成而没有任何错误:
That's it! Re-run the installation; it should complete without any errors:
$ sudo pip install awssh
警告
如果您使用的是基于Debian的Linux系统,则该文件可能是通过python-pkg-resources
软件包安装的.因此,更新或重新安装此软件包将恢复旧模块!另请注意,您正在弄乱应该由apt
控制的文件.
Warning
If you're on a Debian based Linux system, this file might have been installed via the python-pkg-resources
package. Therefore updating or reinstalling this package will reinstate the stale module! Also be aware that you're messing with a file which is supposed to be controlled by apt
.
这篇关于使用pip安装时出现属性错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!