问题:如何修复“ ImportError:无法导入名称IncompleteRead”?
当我尝试使用pip
或安装任何内容时pip3
,我得到:
$ sudo pip3 install python3-tk
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2476, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2190, in load
['__name__'])
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 61, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python3/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python3/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name 'IncompleteRead'
我有一个Ubuntu 14.10系统。
我该如何解决这个问题?
When I try to install anything with pip
or pip3
, I get:
$ sudo pip3 install python3-tk
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2476, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2190, in load
['__name__'])
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 61, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python3/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python3/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name 'IncompleteRead'
I have a Ubuntu 14.10 system.
How can I fix this problem?
回答 0
尽管以前的答案可能是原因,但此片段为我解决了问题(在中Ubuntu 14.04
):
首先从程序包管理器中删除程序包:
# apt-get remove python-pip
然后并行安装最新版本:
# easy_install pip
(感谢@ Aufziehvogel,@ JunchaoGu)
While this previous answer might be the reason, this snipped worked for me as a solution (in Ubuntu 14.04
):
First remove the package from the package manager:
# apt-get remove python-pip
And then install the latest version by side:
# easy_install pip
(thanks to @Aufziehvogel, @JunchaoGu)
回答 1
此问题是由您的pip安装与请求安装之间的不匹配引起的。
根据要求,版本2.4.0 requests.compat.IncompleteRead
已被删除。较旧版本的点子(例如从2014年7月开始)仍然依赖IncompleteRead
。在当前版本的pip中,IncompleteRead
已删除的导入。
因此,应该怪的是:
- 请求,以太快地删除公共API
- Ubuntu的更新点太慢
您可以通过通过Ubuntu更新pip(如果有较新版本)或通过在Ubuntu之外安装pip来解决此问题。
This problem is caused by a mismatch between your pip installation and your requests installation.
As of requests version 2.4.0 requests.compat.IncompleteRead
has been removed. Older versions of pip, e.g. from July 2014, still relied on IncompleteRead
. In the current version of pip, the import of IncompleteRead
has been removed.
So the one to blame is either:
- requests, for removing public API too quickly
- Ubuntu for updating pip too slowly
You can solve this issue, by either updating pip via Ubuntu (if there is a newer version) or by installing pip aside from Ubuntu.
回答 2
要修复pip3(在Ubuntu 14.10上工作):
easy_install3 -U pip
For fixing pip3 (worked on Ubuntu 14.10):
easy_install3 -U pip
回答 3
或者您可以删除所有requests
。
例如:
rm -rf /usr/local/lib/python2.7/dist-packages/requests*
Or you can remove all requests
.
For example:
rm -rf /usr/local/lib/python2.7/dist-packages/requests*
回答 4
在Ubuntu 14.04上,我通过使用pip安装引导脚本解决了此问题,如文档中所述
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
对于开发环境来说,这是一个好的解决方案。
On Ubuntu 14.04 I resolved this by using the pip installation bootstrap script, as described in the documentation
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
That’s an OK solution for a development environment.
回答 5
问题是Python模块requests
。可以通过固定
$ sudo apt-get purge python-requests
[now requests and pip gets deinstalled]
$ sudo apt-get install python-requests python-pip
如果您在Python 3中遇到此问题,则必须编写python3
而不是python
。
The problem is the Python module requests
. It can be fixed by
$ sudo apt-get purge python-requests
[now requests and pip gets deinstalled]
$ sudo apt-get install python-requests python-pip
If you have this problem with Python 3, you have to write python3
instead of python
.
回答 6
这应该为您工作。请遵循以下简单步骤。
首先,让我们删除已经安装的点子,这样就不会引起任何错误。
打开终端。
类型:sudo apt-get remove python-pip
它会删除已安装的点子。
方法1
步骤:1 sudo easy_install -U pip
它将安装pip最新版本。
并将返回其地址:已安装/usr/local/lib/python2.7/dist-packages/pip-6.1.1-py2.7.egg
要么
方法2
步骤:1转到此链接。
步骤:2右键单击>>另存为..,名称为get-pip.py。
步骤:3使用:cd转到与get-pip.py文件相同的目录
步骤:4使用:sudo python get-pip.py
它将安装pip最新版本。
要么
方法3
步骤:1使用:sudo apt-get install python-pip
它将安装pip最新版本。
This should work for you. Follow these simple steps.
First, let’s remove the pip which is already installed so it won’t cause any error.
Open Terminal.
Type: sudo apt-get remove python-pip
It removes pip that is already installed.
Method-1
Step: 1 sudo easy_install -U pip
It will install pip latest version.
And will return its address: Installed /usr/local/lib/python2.7/dist-packages/pip-6.1.1-py2.7.egg
or
Method-2
Step: 1 go to this link.
Step: 2 Right click >> Save as.. with name get-pip.py .
Step: 3 use: cd to go to the same directory as your get-pip.py file
Step: 4 use: sudo python get-pip.py
It will install pip latest version.
or
Method-3
Step: 1 use: sudo apt-get install python-pip
It will install pip latest version.
回答 7
只需运行即可easy_install -U pip
解决我的问题。
Simply running easy_install -U pip
resolved my problem.
回答 8
请检查是否你有一个旧版本的requests
坐在你~/.local/lib/python2.7/site-packages/
并删除它,如果它是(以反映您的Python版本的变化路径)的情况下。这为我解决了这个问题。
Check wether you have an older version of requests
sitting in your ~/.local/lib/python2.7/site-packages/
and remove it if it is the case (change path to reflect your python version). This solved the issue for me.
回答 9
我在ubuntu上的pip版本建议:
pip install --upgrade pip
My version of pip on ubuntu suggests:
pip install --upgrade pip
回答 10
在Windows中,这是通过管理提示进行的:
- 删除
C:\Python27\Lib\site-packages\requests*
easy_install requests==2.3
pip install --upgrade pip
pip install --upgrade requests
In Windows, this worked from an administrative prompt:
- Delete
C:\Python27\Lib\site-packages\requests*
easy_install requests==2.3
pip install --upgrade pip
pip install --upgrade requests
回答 11
我尝试了所有答案,但无法成功。
做到了并且工作了
sudo apt-get purge python-virtualenv
sudo pip install pip -U
之后,我用pip安装了virtualenv
sudo pip install virtualenv
我构建了正在使用的virtualenv,并且该软件包易于安装。通过使用进入virtualenv source /bin/activate
并尝试安装您的软件包,例如:
pip install terminado
它为我工作,尽管我使用的是python2.7而不是python3
I tried with every answer avobe, but couldn’t make it.
Did this and worked
sudo apt-get purge python-virtualenv
sudo pip install pip -U
After that I just installed virtualenv with pip
sudo pip install virtualenv
I built the virtualenv that I was working on and
the package was installed easily.
Get into the virtualenv by using source /bin/activate
and try to install your package, for example:
pip install terminado
It worked for me, although I was using python2.7 not python3
回答 12
检查是否在任何终端窗口中都存在python解释器。如果是这样,请杀死它并尝试sudo pip
对我有用。
Check if have a python interpreter alive in any of the terminal windows. If so kill it and try sudo pip
which worked for me.
回答 13
- sudo apt-get删除python-pip
- sudo easy_install请求== 2.3.0
- 须藤apt-get install python-pip
- sudo apt-get remove python-pip
- sudo easy_install requests==2.3.0
- sudo apt-get install python-pip
回答 14
您可以从以下页面手动下载最新软件包:
然后,通过运行安装它dpkg
:
dpkg -i *.deb
You can download recent packages manually from these pages:
Then, install it by running dpkg
:
dpkg -i *.deb
回答 15
对于CentOS,我使用了它,并且它起作用了,请使用以下命令:
sudo pip uninstall requests
sudo pip uninstall urllib3
sudo yum remove python-urllib3
sudo yum remove python-requests
(确认已删除所有这些库)
sudo yum install python-urllib3
sudo yum install python-requests
For CentOS I used this and it worked please use the following commands:
sudo pip uninstall requests
sudo pip uninstall urllib3
sudo yum remove python-urllib3
sudo yum remove python-requests
(confirm that all those libraries have been removed)
sudo yum install python-urllib3
sudo yum install python-requests