使用 pip 安装时出现属性错误 [英] Attribute Error Installing with pip

查看:29
本文介绍了使用 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:

  1. 启动一个python会话,导入pkg_resources,然后查看加载它的文件:

  1. 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 文件):

    $ 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屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆