today I installed the new Python 3.12 on my Ubuntu 22.04 from the ppa repository ppa:deadsnakes/ppa, everything works, but when I try to install some library with the command python3.12 -m pip install somelibrary, I get the following error
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 165, in exc_logging_wrapper
status = run_func(*args)
^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
return func(self, options, args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 285, in run
session = self.get_default_session(options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 75, in get_default_session
self._session = self.enter_context(self._build_session(options))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 89, in _build_session
session = PipSession(
^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pip/_internal/network/session.py", line 282, in __init__
self.headers["User-Agent"] = user_agent()
^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pip/_internal/network/session.py", line 157, in user_agent
setuptools_dist = get_default_environment().get_distribution("setuptools")
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pip/_internal/metadata/__init__.py", line 24, in get_default_environment
from .pkg_resources import Environment
File "/usr/lib/python3/dist-packages/pip/_internal/metadata/pkg_resources.py", line 9, in <module>
from pip._vendor import pkg_resources
File "/usr/lib/python3/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2164, in <module>
register_finder(pkgutil.ImpImporter, find_on_path)
^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
Any suggestions why this is happening?
EDIT: This problem doesn’t exist when I use venv, it seems to me that the problem is that pip uses /usr/lib/python3 instead of /usr/lib/python3.12
2
Answers
Here is what I did:
Above solution worked for me.
Thank you