using pip3: module “importlib._bootstrap” has no a

2020-01-27 05:48发布

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.

8条回答
够拽才男人
2楼-- · 2020-01-27 06:16

when update python3.4 to python3.6 on ubuntu 14.04. The following solved me:

wget https://bootstrap.pypa.io/ez_setup.py -O - | python3
查看更多
小情绪 Triste *
3楼-- · 2020-01-27 06:16

I met the same problem, this is the key:

curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3
查看更多
▲ chillily
4楼-- · 2020-01-27 06:18

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

查看更多
成全新的幸福
5楼-- · 2020-01-27 06:19

I had the same issue when I tried to install the Slate package in Windows 10, Python 3.7.4 version:

AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

The instruction that generated the error:

C:\WINDOWS\system32>python -m pip install slate

The instruction that worked:

C:\WINDOWS\system32>python -m pip install https://github.com/timClicks/slate/archive/master.zip
查看更多
成全新的幸福
6楼-- · 2020-01-27 06:28

that's because you are using an old version of setuptools, check up this issue.

查看更多
Lonely孤独者°
7楼-- · 2020-01-27 06:32

I am facing the same problem, which is solve by download the source files of the setuptools and install the module manually.

The setuptools can be downloaded here:

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

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

python setup.py intall --user
查看更多
登录 后发表回答