Upgrading python3.4 to python3.6 on ubuntu breaks pip

前端 未结 9 985
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-08 06:56

I\'m attempting to install python3.6 on my machine after I currently have python3.4. However, after installation trying to run pip under python3.6 gives me the

9条回答
  •  北海茫月
    2020-12-08 07:27

    I managed to solve it without installing anything from sources. Here's what I did:

    1. First, install pip for Python3.x (for some weird reason I didn't have it...)

      $ sudo apt-get install python3-pip
      

      It is an old version...

      $ pip3 --version
      pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4)
      
    2. ... so upgrade it to the latest

      $ sudo pip3 install --upgrade pip
      

      Now it is much better

      $ sudo pip3 --version
      pip 9.0.1 from /usr/local/lib/python3.4/dist-packages (python 3.4)
      

    1. Then upgrade virtualenvvwrapper

      $ sudo pip3 install --upgrade virtualenvwrapper
      # ...
      Successfully installed pbr-3.0.1 six-1.10.0 stevedore-1.22.0 virtualenv-15.1.0 virtualenv-clone-0.2.6 virtualenvwrapper-4.7.2
      
    2. Now creating a new virtualenv works:

      $ mkvirtualenv -p `which python3.6` 
      

      pip also works:

      $ pip install django
      # ...
      Successfully installed django-1.11.2 pytz-2017.2
      
      $ pip freeze
      Django==1.11.2
      pytz==2017.2
      

    Note: Now I realize it's a bit more than what you asked for, but (without knowing where exactly you failed) I guess you should be OK after step 2.

提交回复
热议问题