Virtualenv:无法创建 virtualenv:IOError:[Errno 2] 没有这样的文件或目录:'python' [英] Virtualenv: can't create virtualenv: IOError: [Errno 2] No such file or directory: 'python'
问题描述
尝试更新我的 virtualenv 中的 python 安装或创建新的 virtualenv 时会发生这种情况:
This happens when attempting to update the python installation in my virtualenv OR when creating a new virtualenv:
[marcintustin@localhost oneclickrep]$ virtualenv --always-copy --clear --python=/usr/bin/python oneclickcosvirt/
Already using interpreter /usr/bin/python
Deleting tree oneclickcosvirt/lib/python2.7
Not deleting oneclickcosvirt/bin
New python executable in oneclickcosvirt/bin/python
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 9, in <module>
load_entry_point('virtualenv==1.10.1', 'console_scripts', 'virtualenv')()
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 821, in main
symlink=options.symlink)
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 956, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 1377, in install_python
shutil.copyfile(py_executable_base, full_pth)
File "/usr/lib/python2.7/shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: 'python'
[marcintustin@localhost oneclickrep]$
结果始终如上./usr/bin/python
存在并且运行良好(它也是 which
选择的 python).这是什么原因?
The result is consistently the above. /usr/bin/python
exists and is working very nicely (it's also the python picked up by which
). What's the cause here?
使用 virtualenv 1.10.1 版
Using virtualenv version 1.10.1
推荐答案
这是 virtualenv 的一个错误.使用 --always-copy
标志会触发复制行为,这是被破坏的.已经提交了错误报告和补丁.
This is a bug with virtualenv. Using the --always-copy
flag triggers copying behaviour, which is broken. There are bug reports and patches already submitted.
行 shutil.copyfile(py_executable_base, full_pth)
应该是 shutil.copyfile(py_executable, full_pth)
.
这篇关于Virtualenv:无法创建 virtualenv:IOError:[Errno 2] 没有这样的文件或目录:'python'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!