pip3 ImportError: cannot import name 'Incomple

2019-06-16 10:39发布

问题:

Having trouble installing modules via pip3, tried several suggestions from top voted thread from Dec' 2014, but still getting the following:

sudo pip3 install send2trash
    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/__init__.py", line 558, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2355, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2361, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 74, 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'

On Ubuntu 15.10; tried removing python 3 completely and reinstalling, still having issues. Help?

Edit: UPDATE: Tried using my bootable USB to repair Ubuntu and get back to original config and reinstalled via sudo apt-get install python3-pip, but now it generates a crash report saying:

Sorry, the application pip3 has unexpectedly crashed.

回答1:

This seems to be an issue with pip's interaction with the requests package. requests dropped the IncompleteRead module but older versions of pip, which you have, still rely on it, newer versions don't.

You should try updating pip via easy_install-3.5 (if you have Python 3.5) or easy_install-3 for other versions:

sudo easy_install-3.5 -U pip

or:

sudo easy_install-3 -U pip

and you should be good to go.



回答2:

Had similar error on Raspberry Pi. The solution was a combination of all proposals above:

 sudo pip install --upgrade pip
 sudo pip install --upgrade requests
 sudo easy_install3 -U pip


回答3:

It happened me when I tried to install a pip module to my Python3 installation. I mistakenly run pip instead of pip3 and it installed Python2 modules into Python3 installation. After that I realized command was wrong, I run pip3 this time. But, it was no good, installation was blown up, there were errors in Python2 like parenthesis missing in print statement(obviously this is an error for Python3). Eventually, it blown up my terminal too, I needed to install another terminal.

Like you did, I tried to install and reinstall everything, but it didn't work. Fix needed to be done manually. After trying several days and failing, I backed up my files and reinstalled Ubuntu.

I know this is not what you want, but maybe you can save your time by accepting that reinstalling the OS is the easiest solution.



回答4:

Make sure you install newest versions of pip and requests:

pip install --upgrade pip
pip install --upgrade requests