我有2个版本的python - osx&s版本和anaconda版本。
我正在尝试使用我的系统python和virtualenv pip包来执行此操作。
首先:
Alexs-MacBook-Pro-6:kartograph-test alex$ which python
/usr/local/bin/python
Alexs-MacBook-Pro-6:kartograph-test alex$ which virtualenv
/usr/local/bin/virtualenv
Alexs-MacBook-Pro-6:kartograph-test alex$ which pip
/usr/local/bin/pip
所以这些人都在同一个地方。另外,这是我的路径
Alexs-MacBook-Pro-6:kartograph-test alex$ echo $PATH
/usr/local/bin:/Users/alex/anaconda2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
现在我这里是我运行的命令以及输出:
Alexs-MacBook-Pro-6:kartograph-test alex$ virtualenv -p /usr/bin/python2.7 venv
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in venv/bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/alex/kartograph-test/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 "/Library/Python/2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/__init__.py", line 13, in <module>
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/utils/__init__.py", line 15, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Users/alex/kartograph-test/venv/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /Users/alex/kartograph-test/venv/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/virtualenv.py", line 2363, in <module>
main()
File "/Library/Python/2.7/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1004, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 969, in install_wheel
'PIP_NO_INDEX': '1'
File "/Library/Python/2.7/site-packages/virtualenv.py", line 910, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/alex/kartograph-test/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1
现在,当我尝试用/usr/local/bin/python2.7
创建它时,我得到了
Alexs-MacBook-Pro-6:kartograph-test alex$ virtualenv -p /usr/local/bin/python2.7 venv
Running virtualenv with interpreter /usr/local/bin/python2.7
Overwriting venv/lib/python2.7/orig-prefix.txt with new content
New python executable in venv/bin/python2.7
Not overwriting existing python script venv/bin/python (you must use venv/bin/python2.7)
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/virtualenv.py", line 2363, in <module>
main()
File "/Library/Python/2.7/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 994, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1427, in install_python
os.symlink(py_executable_base, full_pth)
OSError: [Errno 17] File exists
我不确定我应该使用哪一个或哪个错误更容易避免。我想要的只是使用python 2.7的1 virtualenv。任何人都可以帮我制作吗?
答案 0 :(得分:2)
rm -rf venv
virtualenv venv
您在第一次尝试时打破了venv
文件夹,第二次尝试无法创建,因为该文件夹存在。
由于适当的python版本在路径中,因此您无需指定它。