using pip3: module "importlib._bootstrap" has no attribute "SourceFileLoader"

Solution 1:

Faced the same problem. I think this is because python3.6 and pip3 were installed from different sources. I suggest using python's inbuilt facility to install pip i.e

python3 -m ensurepip --upgrade

This should install pip3 and pip3.x where x in python3.x. Same works for python2 also.

Solution 2:

I can't edit my existing answer, so I had to add another one:

This worked for me:

sudo pip install python-dotenv

Solution 3:

Tried to install Tensorflow in venv on Windows 10 machine with python 3.8 and got the same issue.

What helped for me was:

pip install setuptools --upgrade

Solution 4:

I had the same problem on my ubuntu 18.04 with python 3.6. None of the above methods helped, but this one solved the problem:

pip3 uninstall setuptools

Solution 5:

I had the same error whatever I asked to pip. I gave a look to this page: https://packaging.python.org/tutorials/installing-packages/

That line is the one that solved my problem:

python3 -m pip install --upgrade pip setuptools wheel