无法创建virtualenv - 糟糕的python路径?

时间:2014-11-10 06:11:16

标签: python django virtualenv anaconda

在试图让django 1.5.1在我的笔记本电脑上运行的软件包之后,我似乎真的搞砸了我的笔记本电脑上安装了python / pip的方法。我的系统上安装了Anaconda。

我目前无法创建虚拟环境。当我运行virtualenv ./temp-env/时,我收到以下错误:

black-rainbows:website User$ virtualenv ./temp-env/

New python executable in ./temp-env/bin/python
Installing setuptools, pip...
  Complete output from command /Users/User/Drop.../temp-env/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/User/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/__init__.py", line 9, in <module>

  File "/Users/User/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/log.py", line 8, in <module>
  File "/Users/User/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/backwardcompat/__init__.py", line 66, in <module>

  File "/Users/User/anaconda/lib/python2.7/urllib2.py", line 94, in <module>
    import httplib
  File "/Users/User/anaconda/lib/python2.7/httplib.py", line 71, in <module>
    import socket
  File "/Users/User/anaconda/lib/python2.7/socket.py", line 47, in <module>
    import _socket
ImportError: dlopen(/Users/User/Dropbox/django/website/temp-env/lib/python2.7/lib-dynload/_socket.so, 2): Symbol not found: __PyInt_AsInt
  Referenced from: /Users/User/Dropbox/django/website/temp-env/lib/python2.7/lib-dynload/_socket.so
  Expected in: dynamic lookup

----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
  File "/Users/User/anaconda/bin/virtualenv", line 11, in <module>
    sys.exit(main())
  File "/Users/User/anaconda/lib/python2.7/site-packages/virtualenv.py", line 824, in main
    symlink=options.symlink)
  File "/Users/User/anaconda/lib/python2.7/site-packages/virtualenv.py", line 992, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/Users/User/anaconda/lib/python2.7/site-packages/virtualenv.py", line 960, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/Users/User/anaconda/lib/python2.7/site-packages/virtualenv.py", line 902, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/User/Drop.../temp-env/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 1

我检查了我的python和virtualenv路径在哪里,它们似乎都在我的Anaconda路径中:

black-rainbows:website User$ which virtualenv
/Users/User/anaconda/bin/virtualenv
black-rainbows:website User$ which python
/Users/User/anaconda/bin/python

但我似乎无法弄清楚问题是什么,谷歌并没有特别有帮助。有什么建议吗?

1 个答案:

答案 0 :(得分:1)

哪个点您已选中which pythonwhich virtualenv。我还要检查which pip。我几乎可以肯定它会和python位于同一个位置,但我会检查(**提示:如果最近可能更改了,请hash -r。)

conda环境 conda拥有自己的虚拟环境设置。您可能已经嗡嗡作响的警告消息警告混合和匹配conda environment和virtualenv环境是一项有风险的业务。预先形成相同魔法的两个系统很可能会结束(如果不是今天他们稍后升级时)。您可能只是在寻找:

conda create -n new_django python django