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
Related
I setup a new Debian 10 (Buster) instance on AWS EC2, and was able to install a pip3 package that depended on netifaces, but when I came back to it the next day the package is breaking reporting an error in netifaces. If I try to run pip3 install netifaces I get the same error:
~$ pip3 install netifaces
Collecting netifaces
Using cached https://files.pythonhosted.org/packages/0d/18/fd6e9c71a35b67a73160ec80a49da63d1eed2d2055054cc2995714949132/netifaces-0.10.9.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 20, in <module>
from setuptools.dist import Distribution, Feature
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 35, 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 55, in <module>
unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
AttributeError: 'HTMLParser' object has no attribute 'unescape'
HTMLParser().unescape was removed in Python 3.9. Compare the code in Python 3.8 vs Python 3.9.
The error seems to be a bug in setuptools. Try to upgrade setuptools. Or use Python 3.8.
I was facing this issue in PyCharm 2018. Apart from upgrading setuptools as mentioned above, I also had to upgrade to PyCharm 2020.3.4 to solve this issue. Related bug on PyCharm issue tracker: https://youtrack.jetbrains.com/issue/PY-39579
Hope this helps someone avoid spending hours trying to debug this.
I had python3.6 and related packages through deb management.
Needed python3.9 for side project and the solution to fix pip and AttributeError: 'HTMLParser' object has no attribute 'unescape'
was to update pip for python3.9 locally for one user:
python3.9 -m pip install --upgrade pip
now installing python3.9 version of the pip-packages work:
python3.9 -m pip install --target=~/.local/lib/python3.9/site-packages numpy
Downgrading to any older python3 version is not the solution and most of the time upgrading setuptools won't fix the issue. The proper solution that worked for me to work with pip using python3.9 is the following on Ubuntu18:
locate /usr/lib/python3/dist-packages/setuptools/py33compact.py33
and change
# unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape) # comment out this line
unescape = getattr(html, 'unescape', None)
if unescape is None:
# HTMLParser.unescape is deprecated since Python 3.4, and will be removed
# from 3.9.
unescape = html_parser.HTMLParser().unescape
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/
>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.
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
I'm getting this error when I try to install pip2.7.
I have python 2.7 as my default already, but I'm not sure why I'm getting this.
OS: CentOS 6.5
OpenSSL has been installed already.
I followed this guide to install Python 2.7:
http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/
[root#myservername arandomfolder]# python get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 17474, in <module>
main()
File "get-pip.py", line 17466, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 17406, in bootstrap
import pip
File "/tmp/tmpXq2wUP/pip.zip/pip/__init__.py", line 10, in <module>
File "/tmp/tmpXq2wUP/pip.zip/pip/util.py", line 18, in <module>
File "/tmp/tmpXq2wUP/pip.zip/pip/_vendor/distlib/version.py", line 14, in <module>
File "/tmp/tmpXq2wUP/pip.zip/pip/_vendor/distlib/compat.py", line 31, in <module>
ImportError: cannot import name HTTPSHandler
You have a Python without SSL support compiled. Unfortunately, get-pip appears to require SSL support.
If you are using a Linux distribution, make sure OpenSSL is installed, including the headers when compiling Python from source.
So looks like i was missing the openssl-devel dependency
after I had installed that, i was able to install this.
I was having this issue on a Centos 6.5 machine even though I had openssl and openssl-devel installed. I was also using the steps from the site:
http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/
I removed python packages I had installed before: virtualenv, NetworkX, and pil:
pip uninstall virtualenv
pip uninstall NetworkX
pip uninstall pil
Then I compiled Python 2.7 again and no longer had this issue. After I followed the steps in the link below, I reinstalled the above packages using pip2.7:
pip2.7 install virtualenv
pip2.7 install NetworkX
pip2.7 install pil --allow-external pil --allow-unverified pil
I have meet the same problem. I solved it by install openssl-devel and reconfigure, make, make install python3:
yum install openssl-devel
then go to the python3 directory:
./configure --with-zlib --with-openssl
make
make install