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

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

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

If you're getting this error running pip install dotenv, this is because the package is called python-dotenv not dotenv.

This worked for me:

sudo pip install python-dotenv

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.