pip3 ImportError: cannot import name 'IncompleteRead' - python

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.

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.

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

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.

Make sure you install newest versions of pip and requests:
pip install --upgrade pip
pip install --upgrade requests

Related

Can't install pip3 for python 3.9

I've tried everything, I've tried doing the following:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.9 get-pip.py
But that just gives me the following error:
root#ubuntu18:~# python3.9 get-pip.py
Traceback (most recent call last):
File "/root/get-pip.py", line 24184, in <module>
main()
File "/root/get-pip.py", line 139, in main
bootstrap(tmpdir=tmpdir)
File "/root/get-pip.py", line 120, in bootstrap
args = determine_pip_install_arguments()
File "/root/get-pip.py", line 65, in determine_pip_install_arguments
import setuptools # noqa
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 14, in <module>
from setuptools.dist import Distribution, Feature
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 24, in <module>
from setuptools.depends import Require
File "/usr/lib/python3/dist-packages/setuptools/depends.py", line 7, in <module>
from .py33compat import Bytecode
File "/usr/lib/python3/dist-packages/setuptools/py33compat.py", line 54, in <module>
unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
AttributeError: 'HTMLParser' object has no attribute 'unescape'
And i've sat hours trying different fixes, when i do pip3 --version it shows that its using python 3.6
And your thinking, why do i need to install it for python 3.9, well the py app im using only supports that and when i try to run it using python3.9 app.py it says that there is missing pip3 modules even though its installed.
I hope someone can tell me a fix, or what's causing the error.
Thanks.
This same thing happened to me, my installation wouldn’t compile correctly because a file in python wasn’t updating from a older version. Just reinstall python 3.9 and retry installing pip3 then it should work. It sucks to do but solves more issues down the road.
Try this command to upgrade setuptools
pip3 install --upgrade setuptools
If that doesnt work , try these
pip3 install --upgrade pip
pip3 install --upgrade distlib

Ubuntu 16.04 pip seems broken

I was installing some packages, after that pip doesn't work anymore. Even if I try some command such as: sudo pip show requets I get this error.
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip import main
File "/usr/local/lib/python3.5/dist-packages/pip/__init__.py", line 28, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python3.5/dist-packages/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/usr/local/lib/python3.5/dist-packages/pip/index.py", line 31, in <module>
from pip.wheel import Wheel, wheel_ext
File "/usr/local/lib/python3.5/dist-packages/pip/wheel.py", line 6, in <module>
import compileall
File "/usr/lib/python3.5/compileall.py", line 20, in <module>
from concurrent.futures import ProcessPoolExecutor
File "/usr/local/lib/python3.5/dist-packages/futures-3.1.1-py3.5.egg/concurrent/futures/__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "/usr/local/lib/python3.5/dist-packages/futures-3.1.1-py3.5.egg/concurrent/futures/_base.py", line 381
raise exception_type, self._exception, self._traceback
^
SyntaxError: invalid syntax
Thanks anyways!
You seem to have installed the futures package on python3.5.
That is a python2 only backport of a python3.2+ package.
You need to delete /usr/local/lib/python3.5/dist-packages/futures-3.1.1-py3.5.egg then it should work again.
You don't need that package on python3.5, it is already included in the standard library.
You should try reinstalling pip if nothing else is working for you. Execute the following:
sudo apt-get install --reinstall python2.7
sudo apt-get purge python-pip
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python get-pip.py
That should work. After doing that, run pip --version and please post the results.
Looks like your pip is broken, can you check pip version using pip --version and maybe upgrading pip to latest version might solve your problem, just try
sudo pip install --upgrade pip , now check pip version and if it still shows the old version try to recreate the simlink using ln -s /usr/local/bin/pip /usr/bin/

ImportError for `python-six` package on Arch Linux

>pip
Traceback (most recent call last):
File "/usr/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 49, in <module>
from pkg_resources.extern import six
File "/usr/lib/python3.6/site-packages/pkg_resources/extern/__init__.py", line 61, in load_module
"distribution.".format(**locals())
ImportError: The 'six' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.
I did reinstall with pacman -S python as well as pacman -S python-setuptools, pacman -S python-packaging, and pacman -S python-six, nothing helps.
Almost every other python applications follow the same pattern now (such as qutebrowser and buku.
I think it happened right after I installed vmware-vcli manually following the ArchWiki guide on the topic (I know its perl and might be unrelated though).
Downgrading python-setuptools as suggesting in similar posts by installing the earlier version in /var/cache/pacman/pkg did not fix the problem.
I faced exactly the same problem running pip3 install --upgrade pip.
However, pip3.5 install --upgrade pip worked for me. After this upgrade the error message of pip3 disappeared.

Error using pelican-quickstart "No module named html_parser"

I decided to give pelican a try, but when I run pelican-quickstart, I get the following dialog:
$ pelican-quickstart
Traceback (most recent call last):
File "/usr/local/bin/pelican-quickstart", line 9, in <module>
load_entry_point('pelican==3.4.0', 'console_scripts', 'pelican-quickstart')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 357, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2394, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2108, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Library/Python/2.7/site-packages/pelican-3.4.0-py2.7.egg/pelican/__init__.py", line 20, in <module>
from pelican.generators import (ArticlesGenerator, PagesGenerator,
File "/Library/Python/2.7/site-packages/pelican-3.4.0-py2.7.egg/pelican/generators.py", line 23, in <module>
from pelican.readers import Readers
File "/Library/Python/2.7/site-packages/pelican-3.4.0-py2.7.egg/pelican/readers.py", line 24, in <module>
from six.moves.html_parser import HTMLParser
ImportError: No module named html_parser `
There was a similar error message in this post, and since I'm running Python 2.7.6 on OS X 10.10 (Yosemite), there may be a similar issue.
What's the best way to address this?
Reinstall Pelican doesn't help me, so I made a little fix in pelican
Modifications were made in following file
/Library/Python/2.7/site-packages/pelican/readers.py
at line 24 place
from six.moves import html_parser
instead of
from six.moves.html_parser import HTMLParser
and at line 299
class _HTMLParser(html_parser.HTMLParser):
instead of
class _HTMLParser(HTMLParser):
Modification actual for pelican 3.6.0, but seems to applicable for other version if search for this lines in readers.py file. This is just quick workaround, hope this problem will be solved at pelican's side.
This error seems to come from Python 2.7.6 on OSX. When I install python via Homebrew and reinstall this module I got rid of this error.
$ pip uninstall pelican
$ brew install python
$ which python # should show /usr/local/bin/python
$ python -V # should show Python 2.7.8
$ pip install pelican
I think that you've probably encountered with version conflict problem in module six.
Try sudo pip install virtualenv to create an isolate python environment.
start
create your pelican path mkdir /path/to/pelican
go to /path/to/pelican and create an isolate python environment with virtualenv venv
activate virtualenv source venv/bin/activate
install pelican under the venv(without sudo!) pip install pelican markdown
done
and now you are free to any problem mentioned above. all the dependencies in the venv are isolated from the global environment.
To quit the venv, type deactivate
I was running into the same error message.
six was also already installed, but an old version (1.4.1)
pip install six --upgrade
Installed six 1.10.0, which made pelican-quickstart finally work :)
You may need to install six.
if you're using pip, try
pip install six
and then restart pelican-quickstart

Please help a newbie install NLTK on Mac OS 10.5.8

I'm completely new to programming. I've been trying various ways to install NLTK on my Mac (running OS 10.5.8), and none of them is working. Please help! Here's what I've done so far.
Since at first I didn't realize that newer versions of Python required OS 10.6 or higher, I first tried to install the latest versions of both Python 3 and Python 2, but this obviously didn't work. I then cottoned on and found an older installation (the filename is python-2.7.6-macosx10.3.dmg), which installed successfully.
I then tried to follow the instructions on this page, which I copy below:
Install Setuptools: http://pypi.python.org/pypi/setuptools
Install Pip: run sudo easy_install pip
Install Numpy (optional): run sudo pip install -U numpy
Install PyYAML and NLTK: run sudo pip install -U pyyaml nltk
Test installation: run python then type import nltk
Steps 1 and 2 worked fine, but when I try steps 3 and 4, I get an error. The error is the same whether I try step 3 or step 4:
unknown0021E9E0E476:~ Tom$ sudo pip install -U numpy
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module> load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 271, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 2173, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 1906, in loadentry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/__init__.py", line 10, in <module>
from pip.util import get_installed_distributions, get_prog
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/util.py", line 17, in <module>
from pip.vendor.distlib import version
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/vendor/distlib/version.py", line 13, in <module>
from .compat import string_types
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/vendor/distlib/compat.py", line 276
return b''
^
SyntaxError: invalid syntax
I then found a different set of instructions on this page. It first has you install Xcode and MacPorts, which I did (again finding older versions compatible with 10.5.8). I got through the next few steps successfully: installed python27, made it the system default (sudo port select --set python python27), and installed the dependencies py27-numpy, py27-yaml, and py27-scipy. However, I can't install one needed package, py27-matplotlib. Here's what happens when I try:
unknown0021E9E0E476:~ Tom$ sudo port install py27-matplotlib
---> Computing dependencies for py27-matplotlib
---> Dependencies to be installed: py27-pyobjc-cocoa py27-pyobjc py27-six py27-tkinter tk Xft2 tcl xorg-libXScrnSaver xorg-scrnsaverproto py27-tornado py27-backports-ssl_match_hostname py27-backports
---> Staging py27-pyobjc into destroot
Error: org.macports.destroot for port py27-pyobjc returned: command execution failed
Error: Failed to install py27-pyobjc
Please see the log file for port py27-pyobjc for details:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_python_py-pyobjc/py27-pyobjc/main.log
Error: The following dependencies were not installed: py27-pyobjc-cocoa py27-pyobjc py27-six py27-tkinter tk Xft2 tcl xorg-libXScrnSaver xorg-scrnsaverproto py27-tornado py27-backports-ssl_match_hostname py27-backports
To report a bug, follow the instructions in the guide:
http://guide.macports.org/#project.tickets
Error: Processing of port py27-matplotlib failed
Without this package, I can't go on to install NLTK.
I've also tried installing NLTK in PyCharm, but that didn't work either: see this question. I'm at my wits' end here, so any help would be much appreciated!
ETA: Problem solved! I downloaded the tar.gz file from https://pypi.python.org/pypi/nltk and followed the install instructions in the package, and now I can import NLTK in the Python shell. Is it possible that I was simply trying to install things while in the wrong directory? (I'd still like to use NLTK in PyCharm, so answers to that question will still be welcome.)
Try installing the scipy package which includes matplotlib and numpy, I was a TA on a course where we used numpy and matplotlib quite a lot and using the scipy package to install was a solution for a lot of people.
The individual binary and source packages are available from: scipy docs
sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose

Categories