Coder Perfect

Using pip3: the attribute “SourceFileLoader” is missing from the module “importlib. bootstrap.”

Problem

On Ubuntu 14, I installed pip for Python 3.6. I’ll run after that.

sudo apt-get install python3-pip

It is quite easy to install pip3. However, when I try to run the program after it has been installed,

pip3 install packagename

Something unusual happens when you try to instal a new package:

File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1479, in <module>
 register_loader-type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module "importlib._bootstrap" has no attribute "SourceFileLoader"

I don’t seem to have done anything wrong, and I’m stumped as to why.

Asked by Arsenal591

Solution #1

I had the same issue. I believe this is due to the fact that python3.6 and pip3 were installed from different locations. To install pip, I recommend utilizing python’s built-in functionality, i.e.

python3 -m ensurepip --upgrade

This should install pip3 and pip3.x where x in python3.x. The same is true for Python 2.

Answered by azhar22k

Solution #2

I couldn’t change my previous answer, so I had to make a new one:

This worked for me:

sudo pip install python-dotenv

Answered by Rod McLaughlin

Solution #3

I attempted to install Tensorflow in venv on a Windows 10 system running Python 3.8 and had the same problem.

What I found to be beneficial was:

—upgrade pip install setuptools

Answered by fbrand

Solution #4

On my Ubuntu 18.04 with Python 3.6, I had the identical issue. None of the ways listed above worked, but this one did:

pip3 uninstall setuptools

Answered by mishadr

Solution #5

Whatever I requested pip to do, I got the same issue. I went to https://packaging.python.org/tutorials/installing-packages/ and looked at it.

That sentence was the key to resolving my issue:

python3 -m pip install --upgrade pip setuptools wheel

Answered by FourchetteVerte

Post is based on https://stackoverflow.com/questions/44761958/using-pip3-module-importlib-bootstrap-has-no-attribute-sourcefileloader