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

前端 未结 9 957
爱一瞬间的悲伤
爱一瞬间的悲伤 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条回答
  • Well, it seems I had a similar problem, but for installing distribute as a dependency by pip.

    I managed to install the dependency in this way (under env):

     easy_install distribute==0.7.3
    

    A piece of error that I ran into:

    File "/tmp/pip-build-lvtkw8zs/distribute/pkg_resources.py", line 1518, in <module>
        register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
    AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
     ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-lvtkw8zs/distribute/
    
    0 讨论(0)
  • 2020-12-08 07:17

    I was having the same issue. It seems I had 2 versions of pkg_resources on my system.

    /usr/local/lib/python3.6/site-packages/pkg_resources.py

    /usr/lib/python3.6/site-packages/pkg_resources/__init__.py

    Moving the old version so my system could find the newer version fixed it for me.

    mv /usr/local/lib/python3.6/site-packages/pkg_resources.py /usr/local/lib/python3.6/site-packages/pkg_resources.py.back

    0 讨论(0)
  • 2020-12-08 07:19

    Had the same problem. Installing python from the source helped.

    # Remove existing python 3.6 if installed with apt
    $ sudo apt-get autoremove python3.6
    
    # Get the source
    $ wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
    $ tar xvf Python-3.6.1.tar.xz
    $ cd Python-3.6.1
    
    # Configure and install
    $ sudo ./configure
    $ sudo make altinstall
    
    # Success!
    $ pip3.6 -V
    pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
    

    Edit: I since discovered pyenv. Makes installing and managing different python versions a lot easier. Give it a try!

    0 讨论(0)
  • 2020-12-08 07:22

    I replaced Python 3.4 with 3.6 on my Ubuntu 14.04 servers and I had the same problem. In my case the cause seemed to be an ancient system pip:

    $ pip --version
    pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
    

    I have never installed python3-pip. Instead I solved the error as follows:

    $ sudo pip install --upgrade pip
    $ sudo pip install --upgrade virtualenv
    
    0 讨论(0)
  • 2020-12-08 07:26

    Just download the file get-pip.py here and use this command:

    sudo python3 get-pip.py
    
    0 讨论(0)
  • 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` <VIRTUALENV_NAME>
      

      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.

    0 讨论(0)
提交回复
热议问题