Django VirtualEnv 设置 - 'setuptools pip wheel failed with error code -11'

Django VirtualEnv Setup - 'setuptools pip wheel failed with error code -11'

我正在学习 Django 的设置教程,我必须在我的文件夹中设置虚拟环境。我没有 virtualenv,所以我做了 sudo pip install virtualenv 并在安装后收到此消息:

Chriss-MacBook-Air:trydjango18 cnowak7$ sudo pip install virtualenv
The directory '/Users/cnowak7/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/cnowak7/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting virtualenv
  Downloading virtualenv-13.1.0-py2.py3-none-any.whl (1.7MB)
    100% |████████████████████████████████| 1.7MB 120kB/s 
Installing collected packages: virtualenv
Successfully installed virtualenv-13.1.0

在此之后,我尝试像教程中那样使用 virtualenv . 创建一个虚拟环境并得到这个异常输出:

Chriss-MacBook-Air:trydjango18 cnowak7$ virtualenv .
Using base prefix '/Users/cnowak7/anaconda'
New python executable in ./bin/python3
Also creating executable in ./bin/python
Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/Users/cnowak7/anaconda/bin/virtualenv", line 11, in <module>
    sys.exit(main())
  File "/Users/cnowak7/anaconda/lib/python3.4/site-packages/virtualenv.py", line 832, in main
    symlink=options.symlink)
  File "/Users/cnowak7/anaconda/lib/python3.4/site-packages/virtualenv.py", line 1004, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/Users/cnowak7/anaconda/lib/python3.4/site-packages/virtualenv.py", line 969, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/Users/cnowak7/anaconda/lib/python3.4/site-packages/virtualenv.py", line 910, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/cnowak7/Deskt...django18/bin/python3 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code -11

所以我试图看看这个错误是否会影响我在教程中的进度,所以当我 运行 source bin/activate 时,我得到了这个错误:

Chriss-MacBook-Air:trydjango18 cnowak7$ source bin/activate
-bash: bin/activate: No such file or directory

我尝试卸载并重新安装 pipvirtualenv,但问题仍然存在。这可能是因为我的 Anaconda 文件夹目录中有 every 吗?任何帮助或建议将不胜感激。谢谢。

试试这个:

sudo easy_install pip

然后:

virtualenv your_virtualenv

我最终通过在我的终端中 www.brew.sh 和 运行 以下命令解决了这个问题:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

根据我的理解,它基本上为我提供了 Apple 最初没有给我的所有我缺少的包和库。我希望这对遇到同样问题的其他人有所帮助。

我和@Rafi 有同样的问题。执行后检查错误消息

virtualenv .

,我从这条错误信息中得到了线索:

dyld: Library not loaded: @rpath/libpython3.6m.dylib

做了一些搜索,发现这意味着 virtualenv 和 Anaconda 在 this link 之间的交互不良。这个简单的解决方案解决了我的问题:

pip uninstall virtualenv
conda install virtualenv