Using pip3: the module "importlib._bootstrap" does not have the attribute "SourceFileLoader"

I installed pip for python 3.6 on Ubuntu 14. After starting

sudo apt-get install python3-pip 

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

 pip3 install packagename 

something strange happens to install 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 do not seem to have done anything wrong, and I really cannot understand the reason.

+24
source share
8 answers

Faced the same problem. I think this is because python3.6 and pip3 were installed from different sources. I suggest using the python built-in tool to install pip ie

 python3 -m ensurepip --upgrade 

This should install pip3 and pip3.x , where x is in python3.x . The same thing works for python2 .

+27
source

I cannot edit my existing answer, so I had to add another one:

This worked for me:

 sudo pip install python-dotenv 
+11
source

when upgrading python3.4 to python3.6 on Ubuntu 14.04. The following solved me:

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

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

pip3 uninstall setuptools

+2
source

I met the same problem, this is the key:

 curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3 
0
source

None of the above helped me

sudo pip install dotenv

produced "AttributeError: the module 'importlib._bootstrap' does not have the attribute 'SourceFileLoader'"

after all of the above (and the suggestions below from Tom Cruise). Python 3.7.2 (built from source) Pip 18.1, Ubuntu 18.04.

0
source

because you are using an old version of setuptools check this issue .

0
source

I am facing the same problem that is solved by downloading the setuptools source files and installing the module manually.

Installation tools can be downloaded here:

 https://pypi.org/project/setuptools/ 

After downloading, first unzip the package, then go to the directory and run

 python setup.py intall --user 
0
source

Source: https://habr.com/ru/post/1269227/


All Articles