virtualenv python broke after upgrading ubuntu 15.10 to 16.04

后端 未结 5 699
渐次进展
渐次进展 2021-02-12 15:41

I had python 3.4 in my virtualenv, but after upgrading ubuntu to 16.04 python upgraded to 3.5 so python in virtualenv crashes with these errors:

Could not find p         


        
5条回答
  •  日久生厌
    2021-02-12 16:23

    I fixed this by installing the minimum working python3.4 so that my virtualenv worked well enough to get the list of packages, then made a new one with python3.5... as follows:

    Get python3.4 minimal packages:

    wget http://launchpadlibrarian.net/221250032/python3.4-minimal_3.4.3-1ubuntu1~14.04.3_amd64.deb
    wget http://launchpadlibrarian.net/221250033/libpython3.4-minimal_3.4.3-1ubuntu1~14.04.3_amd64.deb
    sudo dpkg -i --force-breaks libpython3.4-minimal_3.4.3-1ubuntu1~14.04.3_amd64.deb
    sudo dpkg -i python3.4-minimal_3.4.3-1ubuntu1~14.04.3_amd64.deb
    

    My virtualenv is here: ~/virtualenv/example

    Get the list of packages in your virtualenv (which should now work well enough for this, but might not do other things properly):

    source ~/virtualenv/example/bin/activate
    pip freeze > /tmp/requirements.txt
    deactivate 
    

    Get rid of python3.4, to return to Ubuntu 16.04's preferred state:

    sudo dpkg --purge python3.4-minimal
    sudo dpkg --force-depends --purge libpython3.4-minimal
    

    Make a new virtualenv with the right packages:

    virtualenv -p python3.5 example
    source ~/virtualenv/example/bin/activate
    pip install -r /tmp/requirements.txt
    

    That should now work, with all your old packages but in python3.5. Should...

    See also Upgrade python in a virtualenv

提交回复
热议问题