Python pip 安装报错

标签 python macos installation pip homebrew

我使用 Homebrew 在 Mac OS X 上安装了 Python

$ brew install python

然后我尝试使用 pip 进行更新但出现错误:

$ which python
/usr/local/bin/python
$ python --version
Python 2.7.5
$ pip --version
pip 1.5.4 from /usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg (python 2.7)
$ pip install --upgrade distribute
Downloading/unpacking distribute
  Downloading distribute-0.7.3.zip (145kB): 145kB downloaded
  Running setup.py (path:/private/var/folders/87/wkgwm0754tn9csz8295qjmmc000bxz/T/pip_build_bdkk/distribute/setup.py) egg_info for package distribute

Downloading/unpacking setuptools>=0.7 from https://pypi.python.org/packages/3.4/s/setuptools/setuptools-3.4.4-py2.py3-none-any.whl#md5=46284205a95cf3f9e132bbfe569e1b9d (from distribute)
  Downloading setuptools-3.4.4-py2.py3-none-any.whl (545kB): 545kB downloaded
Installing collected packages: setuptools, distribute
  Found existing installation: setuptools 3.4.1
    Uninstalling setuptools:
      Successfully uninstalled setuptools
  Rolling back uninstall of setuptools
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/req.py", line 1439, in install
    requirement.rollback_uninstall()
  File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/req.py", line 603, in rollback_uninstall
    self.uninstalled.rollback()
  File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/req.py", line 1855, in rollback
    pth.rollback()
AttributeError: 'str' object has no attribute 'rollback'

Storing debug log for failure in /Users/bdkk/.pip/pip.log

有什么想法吗?

最佳答案

在尝试安装 distribute 之前单独升级 setuptools:

pip install --upgrade setuptools
pip install --upgrade distribute

关于Python pip 安装报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23276866/

相关文章:

python - 将Numpy图像数组转换为1px高版本

python - 如何使用 pyarrow 将 Pandas 数据帧设置/获取到 Redis

swift - 如何允许用户将文件拖出 Cocoa App

java - 想要隐藏/删除屏幕菜单栏

c++ - 如何在二进制发行版中提供资源文件的路径?

python - 在 MySQLdb 中使用变量作为字段名称,Python 2.7

python - 如何使用零配置的 Sphinx 生成 Python 文档?

c++ - Qt3D 应用程序在按下任何按钮时触发系统声音

python - 安装Python 3后如何安装Open CV?

c# - 使用 Wix Bootstrapper (Burn) 安装 .NET 可再发行组件