Can't install pip3 for python 3.9

Viewed 1437

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.

2 Answers

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