尝试更新virtualenv中的python安装或创建新的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)。这是什么原因?
编辑:使用virtualenv版本1.10.1
答案 0 :(得分:4)
这是virtualenv的错误。使用--always-copy
标志会触发复制行为,该行为已被破坏。已经提交了错误报告和补丁。
第shutil.copyfile(py_executable_base, full_pth)
行应为shutil.copyfile(py_executable, full_pth)
。