Reputation: 786
So I used virtualenv
to define environments for a number of projects I am working on. I defined the virtualenv
python as being version 3.4. Eventually, my global python was upgraded from 3.4.0 to 3.4.3. This proved to be a problem because the virtualenv
was dependent on the global binaries (the contents of /lib/python3.4
in my virtualenv
is actually just links to the global binaries), and these aren't defined up to their minor versions. In other words, when the upgrade was done, the contents of the binary folder /usr/lib/python3.4
was replaced. This is because python doesn't install things separately in 3.4.0 and 3.4.3 but only into a single folder named /usr/lib/python3.4
. Since the python executable in my virtualenv
was 3.4.0, there were obviously compatibility issues with the 3.4.3 binaries (it would fail to load ctypes
which prevented just about anything python dependent to run). The only fix to this I've found is to downgrade my global python installation, but this feels "dirty". What if I had one project running 3.4.0 and another running 3.4.3 ? Is there no way to make them work in parallel on the same machine given that only one binary folder can exist for any 3.4.x installation ?
I'm trying to understand if I'm missing something obvious here or if this is a common problem with virtualenv
, given that I've heard quite a few people complain about issues with binares when using virtualenv
.
In the future, is there anyway of telling virtualenvwrapper
to copy the binaries rather than link to them ?
Upvotes: 2
Views: 421
Reputation: 36765
Virtualenvs were not desiged to be portable, both across machines or across Python versions.
This means upgrading Python versions sometimes breaks virtualenvs. You need to recreate them and reinstall everything inside of it (run this in your virtualenv root):
# Save a list of what you had installed
pip freeze > freeze.txt
# Trash the entire virtualenv
deactivate
rm -rf lib/ bin/ share/ man/ include/ .Python pip-selfcheck.json
# Create it anew
virtualenv .
# Install all libraries you had before
pip install -r freeze.txt
Upvotes: 3