问:如何解决这个 pip 安装问题?
我尝试安装一些库
pip3 install pinecone-client openai tiktoken langchain
这发生了:
$ pip3 install pinecone-client openai tiktoken langchain
Traceback (most recent call last):
File "/usr/bin/pip3", line 11, in <module>
load_entry_point('pip==20.0.2', 'console_scripts', 'pip3')()
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.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, 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)
我是 python 新手,所以我不确定解决它的最佳方法。谢谢。
答案1
- 使用Python3.10(默认)
切换回 Ubuntu Jammy 的默认 python 版本 Pyhon3.10。更改Ubuntu中的Python3默认版本
- 使用Python3.11
从官方存储库安装Python3.11:
Python3.11 可从jammy-updates universe
存储库获取。您的 中应该有以下行/etc/apt/sources.list
:
deb http://de.archive.ubuntu.com/ubuntu/ jammy-updates main universe
从第三方存储库(或编译的)中删除已安装的Python3.11,然后:
sudo apt remove python3.11
sudo apt update
sudo apt install python3.11
pip
检查Python3.11是否正常工作:
python3.11 -m pip install pinecone-client openai tiktoken langchain