【问题标题】:Python Pip Install "Egg" Error (Pandas and other modules)Python Pip 安装“Egg”错误(Pandas 和其他模块)
【发布时间】:2015-02-28 06:08:33
【问题描述】:

在安装一些 python 模块(例如 pandas)时遇到问题,并且在安装 ipython notebook 时遇到了一些问题。

其他人 (Python pip install fails: invalid command egg_info) 之前似乎出现过此错误,但他们使用的是 Python 2.7,而我使用的是 2.6(默认使用我的 Mac OS 10.6)。我也尝试了 easy_install -U setuptools 和 pip install --upgrade setuptools 但都没有奏效。

这是我安装 pandas 时遇到的错误:

Command python setup.py egg_info failed with error code 1 in /private/var/folders/Wm/WmmbYincEnuCrAMtGBudAk+++TM/-Tmp-/pip_build_AWal/pandas
Storing debug log for failure in /Users/AWal/Library/Logs/pip.log

对于安装 iPython,这是我得到的错误:

Exception:
Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/req.py", line 1435, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/req.py", line 671, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/req.py", line 901, in move_wheel_files
    pycompile=self.pycompile,
  File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/wheel.py", line 341, in move_wheel_files
    generated.extend(maker.make_multiple(['%s = %s' % kv for kv in console.items()]))
  File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/_vendor/distlib/scripts.py", line 316, in make_multiple
    filenames.extend(self.make(specification, options))
  File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/_vendor/distlib/scripts.py", line 305, in make
    self._make_script(entry, filenames, options=options)
  File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/_vendor/distlib/scripts.py", line 209, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/_vendor/distlib/scripts.py", line 189, in _write_script
    self._fileop.write_binary_file(outname, script_bytes)
  File "/Library/Python/2.6/site-packages/pip-1.5.4-py2.6.egg/pip/_vendor/distlib/util.py", line 384, in write_binary_file
    with open(path, 'wb') as f:
IOError: [Errno 13] Permission denied: '/usr/local/bin/sphinx-apidoc'

Storing debug log for failure in /Users/AWal/Library/Logs/pip.log

有什么想法吗?

更新:

当我执行 sudo pip install pandas(另一个我无法安装的模块)时,我得到一个很长的回溯,并带有结束错误消息:

RuntimeError: Broken toolchain: cannot link a simple C program

回溯(大约 100 行的样本)如下所示:

Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/private/tmp/pip_build_root/pandas/setup.py", line 619, in <module>

    **setuptools_kwargs)

  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/core.py", line 113, in setup

  File "build/bdist.macosx-10.6-universal/egg/setuptools/dist.py", line 266, in __init__

  File "build/bdist.macosx-10.6-universal/egg/setuptools/dist.py", line 312, in fetch_build_eggs

  File "build/bdist.macosx-10.6-universal/egg/pkg_resources/__init__.py", line 753, in resolve

  File "build/bdist.macosx-10.6-universal/egg/pkg_resources/__init__.py", line 1005, in best_match

  File "build/bdist.macosx-10.6-universal/egg/pkg_resources/__init__.py", line 1017, in obtain

  File "build/bdist.macosx-10.6-universal/egg/setuptools/dist.py", line 379, in fetch_build_egg

  File "build/bdist.macosx-10.6-universal/egg/setuptools/command/easy_install.py", line 619, in easy_install

【问题讨论】:

  • 用管理员权限试试
  • @Hackaholic 试过 sudo pip install pandas (另一个不工作的模块),我得到了同样的错误:命令 python setup.py egg_info failed with error code 1 in /private/tmp/pip_build_root/ pandas 在 /Users/AWal/Library/Logs/pip.log 中存储失败的调试日志
  • 您的 OS X 上是否安装了 XCode(以及它自带的工具)?
  • @user3736169 是的,您可以从 Mac App Store 下载它。不是 100% 肯定,但我认为安装和打开它可以让所有基于 C 的编译工具栩栩如生。

标签: python macos installation pip easy-install


【解决方案1】:

权限被拒绝消息会建议您按照 Hackaholic 的建议以 root 身份运行命令。 试试sudo pip install YOUR_PACKAGE

您可能还想查看virtualenv 以使用更加孤立的环境。 在基于 debian 的发行版下,您可以使用 apt-get install python-virtualenv 安装 python-virtualenv 包。

然后通过键入virtualenv whatever 创建一个虚拟环境名称(这将在当前文件夹中创建一个文件夹whatever。 然后cd 输入bin/activate 进入这个虚拟环境。 从那里再次尝试您的pip install 命令。

可能有帮助

更新: 您可以尝试使用建议的解决方案here

总而言之,尝试在~/.bash_profile 中添加export ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future

【讨论】:

  • 基本上,virtualenv 是一个不错的选择。要将其安装在 Mac 上(没有apt-get),您可以关注此post。但是,OP 中的更新表明 C 编译器可能存在问题,这也需要解决。
  • @sthzg 我认为这绝对是编译器的问题。我只是尝试在 bash_profile 以及一个模块(这次是 numpy,另一个不为我安装的模块)中命令 export ARCHFLAGS: sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-未来的错误 pip install --upgrade numpy.不幸的是,我遇到了另一个错误: Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip_build_root/numpy/setup.py';exec(compile(getattr(tokenize, 'open ', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" 等....
  • @user3736169 在之前的link i gave you 中,有些人解释说他们只需要打开 XCode 一种类型并按照此建议接受协议:I simply had to open XCode and accept the agreement and let it install the tools. 可能也会对您有所帮助。
【解决方案2】:

这个问题首先出现在 Google 中,但 second 确实有效:

pip install -U setuptools

pip install ez_setup

【讨论】:

    猜你喜欢
    • 2018-02-06
    • 1970-01-01
    • 1970-01-01
    • 2018-09-24
    • 1970-01-01
    • 2016-04-28
    • 2014-06-10
    • 2015-09-10
    • 2021-06-04
    相关资源
    最近更新 更多