本文介绍了使用 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