virtualenv python broke after upgrading ubuntu 15.10 to 16.04

后端 未结 5 704
渐次进展
渐次进展 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:31

    I had the same problem today and that is how I have solved it:

    Problem: Firstly, as I understand, the problem occurs because after upgrading to Ubuntu 16.04 the previous version of Python also upgrades. As a result symbolic links inside any Python3 environment are not working anymore.

    Solution 1: As it was written above the straightforward solution is to remove all the Python3 environments and create them again. I don't like it because it is second time I do it after upgrading Ubuntu. Also probably I need to use multiple Python 3 versions in the future projects.

    Solution 2: That is what I have tried today and it is working fine. Instead of using virtualenv + virtualenvwrapper I decided to try combination of pyenv + pyenv-virtualenv.

    The main difference between two approaches is:

    Pyenv actually copies an entire Python installation every time you create a new pyenv version. In contrast, virtualenv makes use of symbolic links to decrease the size of the virtualenv’s.

    Howto:

    1. Install pyenv as described here together with required versions of Python 2 and 3.
    2. Have a look here on how you can work with virtualenv using pyenv.
    3. Create new environment, install all the dependencies with pip and hopefully forget about the problem of broken symlinks during next Ubuntu upgrade.

提交回复
热议问题