Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After OS python upgrade, virtualenv python failing with "undefined symbol: _PyLong_AsInt¨ error on simple tasks

I had a long-working virtualenv based on python-2.7.3. After accepting recommended platform OS (Ubuntu) updates which (among many other changes) brought python up to 2.7.6, the python inside the virtualenv has started erroring on essentially all non-trivial tasks, with stacks ending like:

ImportError: /home/myusername/ENVS/myvenv/lib/python2.7/lib-dynload/_io.so: undefined symbol: _PyLong_AsInt

Even pip freeze is failing with such an error -- making it impossible to even get an accurate inventory of installed packages in the broken virtualenv (for potentially reinstalling into a fresh working virtualenv)!

Shouldn't the virtualenv be protected from such outside upgrades? Or at least within the 2.7.x series?

like image 592
gojomo Avatar asked Aug 04 '14 16:08

gojomo


People also ask

Can I upgrade Python version in Virtualenv?

You can't upgrade to a Python version you don't already have on your system somewhere, so make sure to get the version you want, first, then make all the venvs you want from it. Save this answer. Show activity on this post.

How do I uninstall Virtualenv?

There is no command for deleting your virtual environment. Simply deactivate it and rid your application of its artifacts by recursively removing it. Note that this is the same regardless of what kind of virtual environment you are using.


1 Answers

You can simply do

cp /usr/bin/python2 /path/to/my-virtualenv/bin/python2

or

cp /usr/bin/python3 /path/to/my-virtualenv/bin/python3
like image 111
aiai Avatar answered Nov 04 '22 07:11

aiai