Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

222
Visualizações
Upgrading python3.4 to python3.6 on ubuntu breaks pip

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 error:

Traceback (most recent call last):
  File "pip3", line 7, in <module>
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 59, in <module>
    from pip.log import logger
  File "/usr/lib/python3/dist-packages/pip/log.py", line 9, in <module>
    import colorama, pkg_resources
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1520, in <module>
    register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 20, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "pip3", line 7, in <module>
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 59, in <module>
    from pip.log import logger
  File "/usr/lib/python3/dist-packages/pip/log.py", line 9, in <module>
    import colorama, pkg_resources
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1520, in <module>
    register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

There were several comments on the internet about that error being encountered, However, none of them contain any actual resolution suggestion. Does anyone have any idea how I could fix this?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

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.

over 4 years ago · Santiago Trujillo Relatório

0

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!

over 4 years ago · Santiago Trujillo Relatório

0

I could not solve it by running

python3 get-pip.py

or

pip3 install --upgrade

because there I already had issues with pkg_resources.py. Also re-installing the python3-setuptools package from Ubuntu did not help as this still seems to install the one for the version originally installed with the Ubuntu system (3.4 in my case) but I could solve it by manually installing the setuptools via

wget https://bootstrap.pypa.io/ez_setup.py -O - | python3

Note: python3 points to my new python version 3.6. If thats not the case for you then you would need to run

wget https://bootstrap.pypa.io/ez_setup.py -O - | python3.6
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda