Virtualenv 导致 setuptools 错误

Virtualenv causing setuptools error

我在 运行 virtualenv 上遇到了问题,而且我一直收到同样的错误代码:"setuptools pip wheel failed with error code 1"

我看到一些页面在谈论不同版本的 setuptools 之间的差异,但我已经卸载并重新安装了几个版本的 virtualenv 和 setuptools,但没有结果。有人知道这里发生了什么吗?

Roberts-MacBook-Air:script Rob$ virtualenv venv
New python executable in venv/bin/python
Installing setuptools, pip, wheel...
  Complete output from command /Users/Rob/Seedstages/script/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/__init__.py", line 13, in <module>
  File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/utils/__init__.py", line 15, in <module>
  File "/Users/Rob/anaconda/lib/python2.7/zipfile.py", line 6, in <module>
    import io
  File "/Users/Rob/anaconda/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: dlopen(/Users/Rob/Seedstages/script/venv/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException
  Referenced from: /Users/Rob/Seedstages/script/venv/lib/python2.7/lib-dynload/_io.so
  Expected in: dynamic lookup

----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/Users/Rob/anaconda/bin/virtualenv", line 11, in <module>
    sys.exit(main())
  File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 832, in main
    symlink=options.symlink)
  File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 1004, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 969, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 910, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/Rob/Seedstages/script/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1
Roberts-MacBook-Air:script Rob$

我会说 Anaconda 导致了冲突,但更具体地说,似乎 Anaconda 的 virtualenv 是问题所在。 运行 which virtualenv 在我的 macbook 上(我遇到了同样的问题)产生 /Users/me/anaconda/bin/virtualenv 而 运行 在 linux 系统上我刚刚测试了这个产量/usr/local/bin/virtualenv.

所以,在 OS X 上,我使用 /usr/local/bin/pip install virtualenv 下载了 virtualenv。这不会在 PATH 文件夹中创建 virtualenv 二进制文件(或者它不会为我创建),所以我不得不输入这个痛苦的长命令:

sudo /usr/local/bin/python ... {the path to virtualenv.py in the system python's site-packages folder} new_env

就是这样。但这是荒谬的。没有人愿意这样做 - 即使创建链接在您不需要时仍然会被破解。

根据 ContinuumIO github 页面 on this very subjectvirtualenv envsource /bin/activate 命令已替换为 conda create -n env python=2.7source activate env

在我的 macbook 上测试(运行 Anaconda2 v4 on OS Yosemite)并且成功了。