Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have installed pip for python 3.6 on Ubuntu 14. After I run

sudo apt-get install python3-pip

to install pip3, it works very well. However, after installation, when I am trying to run

pip3 install packagename

to install a new package, something strange occurs:

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"

It seems that I did nothing wrong, and I really cannot figure out the reason.

like image 544
Arsenal591 Avatar asked Jun 26 '17 14:06

Arsenal591


3 Answers

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
like image 44
Rod McLaughlin Avatar answered Nov 04 '22 16:11

Rod McLaughlin


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.

like image 142
azhar22k Avatar answered Nov 04 '22 16:11

azhar22k


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
like image 28
fbrand Avatar answered Nov 04 '22 17:11

fbrand