本文介绍了使用pip3:模块"importlib._bootstrap";没有属性"SourceFileLoader";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Ubuntu 14上为python 3.6安装了pip.运行后

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

sudo apt-get install python3-pip

安装pip3,效果很好.但是,安装后,当我尝试运行

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.

推荐答案

遇到了同样的问题.我认为这是因为python3.6pip3是从不同来源安装的.我建议使用python的内置工具来安装pip,即

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

这应该安装pip3pip3.x,其中x在python3.x中.python2同样适用.

This should install pip3 and pip3.x where x in python3.x.Same works for python2 also.

这篇关于使用pip3:模块"importlib._bootstrap";没有属性"SourceFileLoader";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 10:23
查看更多