所以此问题已经提出,但我没有找到适当的解决方案。
我在Mac上。当我在终端中运行python时,我得到:
Python 2.7.6 |Anaconda 1.9.2 (x86_64)| (default, Jan 10 2014, 11:23:15)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
我真的不明白这意味着什么,它是用Anaconda运行Python 2.7.6吗?
无论如何,我的问题是我无法设置virtualenv。当我尝试创建虚拟环境时,我收到以下错误消息:
New python executable in virtualenvs/bin/python
Installing setuptools, pip...
Complete output from command /Users/arashsaidi/virtualenvs/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
Ignoring indexes: https://pypi.python.org/simple/
Exception:
Traceback (most recent call last):
File "/Users/arashsaidi/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/Users/arashsaidi/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/commands/install.py", line 236, in run
session = self._build_session(options)
File "/Users/arashsaidi/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/basecommand.py", line 52, in _build_session
session = PipSession()
File "/Users/arashsaidi/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/download.py", line 216, in __init__
super(PipSession, self).__init__(*args, **kwargs)
File "/Users/arashsaidi/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/_vendor/requests/sessions.py", line 273, in __init__
self.headers = default_headers()
File "/Users/arashsaidi/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/_vendor/requests/utils.py", line 555, in default_headers
'User-Agent': default_user_agent(),
File "/Users/arashsaidi/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/_vendor/requests/utils.py", line 524, in default_user_agent
_implementation = platform.python_implementation()
File "/Users/arashsaidi/anaconda/lib/python2.7/platform.py", line 1499, in python_implementation
return _sys_version()[0]
File "/Users/arashsaidi/anaconda/lib/python2.7/platform.py", line 1464, in _sys_version
repr(sys_version))
ValueError: failed to parse CPython sys.version: '2.7.5 (default, Aug 25 2013, 00:04:04) \n[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]'
Storing debug log for failure in /var/folders/jg/hs6w4q8x10n4ycwwf06dnp440000gn/T/tmpmM9rRS
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "/Users/arashsaidi/anaconda/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/Users/arashsaidi/anaconda/lib/python2.7/site-packages/virtualenv.py", line 824, in main
symlink=options.symlink)
File "/Users/arashsaidi/anaconda/lib/python2.7/site-packages/virtualenv.py", line 992, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Users/arashsaidi/anaconda/lib/python2.7/site-packages/virtualenv.py", line 960, in install_wheel
'PIP_NO_INDEX': '1'
File "/Users/arashsaidi/anaconda/lib/python2.7/site-packages/virtualenv.py", line 902, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/arashsaidi/virtualenvs/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 2
你能帮我找一个解决方案吗?
答案 0 :(得分:4)
virtualenv包不适用于Anaconda。在终端提示符下,您应该使用conda语句conda -n new_env_name
创建一个新的虚拟环境,如in the docs所述。
答案 1 :(得分:1)
在我的Ubuntu15.10上使用anaconda很不错,但使用virtualenv / virtualenvwrapper / pyvenv来创建虚拟环境就是“ISIBDWYHI”
这是我的方式。 1.注释#export PATH =“/ your / path / to / anaconda3 / bin:$ PATH”来自〜/ .bashrc 2.重新启动终端并在任何地方创建虚拟环境。 3.使导出PATH =“/ your / path / to / anaconda3 / bin:$ PATH”返回。
答案 2 :(得分:0)
尝试。
sudo pip install --upgrade virtualenv
或sudo pip install virtualenv==1.10.1
答案 3 :(得分:0)
找到解决我问题的方法。我安装了旧版本的anaconda,这使得安装和创建virtualenv成为可能。这不是一个很好的解决方案,但我觉得我已经尝试了大多数我能想到的解决方案......
答案 4 :(得分:0)
OP的问题实际上是他有多个版本的python,在他的系统PATH中,anaconda python首先问世。他试图在他的conda环境中使用virtualenv,这就是他犯错误的原因。 他实际上可以将常规python(w / virtualenv)和anaconda python安装在一起,只要他知道哪个python是哪个,他仍然可以使用常规python运行virtualenv。
答案 5 :(得分:0)
Anaconda Python可以与virtualenvs一起使用,只要您通过conda安装virtualenv软件包即可。使用--force-reinstall
确定。
conda install --force-reinstall virtualenv