Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Cannot upgrade python #437

Open
Kentzo opened this Issue Jun 18, 2013 · 8 comments

Comments

Projects
None yet
6 participants

Kentzo commented Jun 18, 2013

Script fails with the following error:

OSError: [Errno 17] File exists: '/Users/kentzo/.virtualenvs/…/lib/python2.7/config'
Owner

pfmoore commented Jun 18, 2013

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?

Kentzo commented Jun 18, 2013

@pfmoore Mac OS X 10.8.4, virtualenv 1.9.1

virtualenv ~/.virtualenvs/MyVirtualEnv 
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
no_pip=options.no_pip)
  File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 1081, in create_environment
site_packages=site_packages, clear=clear))
  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
copyfileordir(src, dest)
  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
    os.makedirs(dst)
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 17] File exists: '/Users/kentzo/.virtualenvs/MyVirtualEnv/lib/python2.7/config'
Owner

pfmoore commented Jun 18, 2013

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?

Kentzo commented Jun 19, 2013

@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.

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.

Contributor

jhermann commented Sep 17, 2014

BTW, a local devpi-server is a solution for the "takes a long time" problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment