今天我从ppa仓库ppa:deadsnakes/ppa在我的Ubuntu 22.04上安装了新的Python 3.12,一切正常,但是当我尝试用命令python3.12 -m pip install somelihood安装一些库时,我得到以下错误
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'?
有什么建议吗?
编辑:当我使用venv时,这个问题不存在,在我看来,问题是pip使用/usr/lib/python3而不是/usr/lib/python3。
1条答案
按热度按时间tmb3ates1#
我是这么做的: