Script fails with the following error:
OSError: [Errno 17] File exists: '/Users/kentzo/.virtualenvs/…/lib/python2.7/config'
Please can you provide details of precisely what fails. What command did you run, what OS are you on (OSX?), what was the complete output?
@pfmoore Mac OS X 10.8.4, virtualenv 1.9.1
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 9, in <module>
load_entry_point('virtualenv==1.9.1', 'console_scripts', 'virtualenv')()
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 979, in main
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 1081, in create_environment
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 1275, in install_python
copyfile(join(stdlib_dir, fn), join(lib_dir, fn))
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 437, in copyfile
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 412, in copyfileordir
shutil.copytree(src, dest, True)
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 177, in copytree
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
OSError: [Errno 17] File exists: '/Users/kentzo/.virtualenvs/MyVirtualEnv/lib/python2.7/config'
Thanks. Looks like you're trying to run virtualenv on an existing directory. I didn't think that was valid usage (my assumption was that if you want a new version of Python, you should recreate the virtualenv from scratch) but that may just be because I never use virtualenv like that.
There's nothing in the documentation to indicate that this is allowed (although nothing much says it's forbidden, either). The error seems to imply that it's not expected to work. Do any of the other developers have a view on whether this is valid usage? @qwcode any comments?
@pfmoore I think virtualenv should provide some mechanism of either upgrading python within virtualenv or migrating site packages from old virtualenv to new.
This is a popular need. See http://stackoverflow.com/questions/10218946/upgrade-python-in-a-virtualenv which suggests that it now works (on Linux?) for point releases of Python (which may be really all we can expect.)
+1 for making this easy. I have dozens of virtualenvs and they keep breaking as I upgrade python. Very time consuming to have to recreate them - and difficult too since it's too late to pip freeze >requirements.txt once they're broken.
pip freeze >requirements.txt
Upgrading Python (same version, different build) breaks my virtualenv too. I find out that removing all python executables from the virtual env then re-virtualization can succeed. But the standard Python modules seem untouched, which means that I have still inconsistent files running together (now the virtual env is using the new binary and shared libraries, but still old *.py modules).
After I remove them and retry, they result in symlinks to system ones. This is better, but if there were new standard modules it would still break and require re-virtualize. Fortunately there won't for 2.7 :-)
Using a fresh virtualenv is a headache, since pip doesn't cache downloaded tarballs / cloned git repositories it'll take very long to install for me.
BTW, a local devpi-server is a solution for the "takes a long time" problem.