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:35

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.

查看更多
疯言疯语
3楼-- · 2020-01-27 06:35

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

This worked for me:

sudo pip install python-dotenv
查看更多
登录 后发表回答