Marcin
Marcin

Reputation: 49826

Virtualenv: can't create virtualenv: IOError: [Errno 2] No such file or directory: 'python'

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]$ 

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?

Edit: Using virtualenv version 1.10.1

Upvotes: 2

Views: 2712

Answers (1)

Marcin
Marcin

Reputation: 49826

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.

The line shutil.copyfile(py_executable_base, full_pth) should be shutil.copyfile(py_executable, full_pth).

Upvotes: 4

Related Questions