Home > other >  Pip is not working for Python 3.10 on Ubuntu
Pip is not working for Python 3.10 on Ubuntu

Time:10-12

I am new to using Ubuntu and Linux in general. I just attempted to update Python by using sudo apt-get install python3.10. When I run python3.10 -m pip install <library name> I always receive the following error:

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3/dist-packages/pip/__main__.py", line 19, in <module>
    sys.exit(_main())
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/__init__.py", line 96, in create_command
    module = importlib.import_module(module_path)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 24, in <module>
    from pip._internal.cli.req_command import RequirementCommand
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 15, in <module>
    from pip._internal.index.package_finder import PackageFinder
  File "/usr/lib/python3/dist-packages/pip/_internal/index/package_finder.py", line 21, in <module>
    from pip._internal.index.collector import parse_links
  File "/usr/lib/python3/dist-packages/pip/_internal/index/collector.py", line 12, in <module>
    from pip._vendor import html5lib, requests
ImportError: cannot import name 'html5lib' from 'pip._vendor' (/usr/lib/python3/dist-packages/pip/_vendor/__init__.py)```

I have tried doing sudo apt-get install python3.10-html5lib it downloaded something but it did not fix the error. How should I fix this error?

CodePudding user response:

At the time of writing and as stated on the following link. Python 3.10 is still unstable. Maybe it is a good idea to test what happens with python3.9 and see if the issue is in your local installation.
in any case, from a clean ubuntu (docker) installation by running (with sudo rights)

apt-get install software-properties-common 
apt-get install python3.9
python3.9 --version
#
apt-get install python3.10
python3.10 --version

I got an the answers Python 3.9.5 and bash: python3.10: command not found respectively. so I guess the issue could be in the python 3.10 repository... for now.

However, apt-get install will not update directly your "default" python. You can check which are your those installations with

python --version
python3 --version

Any way, if you still want to install python3.10, perhaps the link above could help you.

CodePudding user response:

This is likely caused by a too old system pip version.

Install the latest with:
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

  • Related