这是什么错误啊?
(huoshan_asr_service) sunyuhua@sunyuhuadeMacBook-Pro huoshan_asr_service %
(huoshan_asr_service) sunyuhua@sunyuhuadeMacBook-Pro huoshan_asr_service % pip install -r requirements.txt
Collecting fastapi==0.104.1 (from -r requirements.txt (line 1))
Using cached fastapi-0.104.1-py3-none-any.whl.metadata (24 kB)
Collecting uvicorn==0.24.0 (from -r requirements.txt (line 2))
Using cached uvicorn-0.24.0-py3-none-any.whl.metadata (6.4 kB)
Collecting websockets==11.0.3 (from -r requirements.txt (line 3))
Using cached websockets-11.0.3-py3-none-any.whl.metadata (6.6 kB)
Collecting aiohttp==3.9.0 (from -r requirements.txt (line 4))
Using cached aiohttp-3.9.0.tar.gz (7.5 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting numpy==1.24.3 (from -r requirements.txt (line 5))
Using cached numpy-1.24.3.tar.gz (10.9 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [32 lines of output]
Traceback (most recent call last):
File "/Users/sunyuhua/miniconda3/envs/huoshan_asr_service/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
main()
~~~~^^
File "/Users/sunyuhua/miniconda3/envs/huoshan_asr_service/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
json_out["return_val"] = hook(**hook_input["kwargs"])
~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sunyuhua/miniconda3/envs/huoshan_asr_service/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 137, in get_requires_for_build_wheel
backend = _build_backend()
File "/Users/sunyuhua/miniconda3/envs/huoshan_asr_service/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 70, in _build_backend
obj = import_module(mod_path)
File "/Users/sunyuhua/miniconda3/envs/huoshan_asr_service/lib/python3.13/importlib/__init__.py", line 88, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/private/var/folders/zz/g95wt6fx5qlccq9lm64hjjb80000gn/T/pip-build-env-_5z0r14b/overlay/lib/python3.13/site-packages/setuptools/__init__.py", line 16, in <module>
import setuptools.version
File "/private/var/folders/zz/g95wt6fx5qlccq9lm64hjjb80000gn/T/pip-build-env-_5z0r14b/overlay/lib/python3.13/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/private/var/folders/zz/g95wt6fx5qlccq9lm64hjjb80000gn/T/pip-build-env-_5z0r14b/overlay/lib/python3.13/site-packages/pkg_resources/__init__.py", line 2172, in <module>
register_finder(pkgutil.ImpImporter, find_on_path)
^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
(huoshan_asr_service) sunyuhua@sunyuhuadeMacBook-Pro huoshan_asr_service %
fastapi==0.104.1
uvicorn==0.24.0
websockets==11.0.3
aiohttp==3.9.0
numpy==1.24.3
pydantic==2.5.0
python-multipart==0.0.6
你现在用的是 Python 3.13 的虚拟环境,但 requirements.txt 里固定了很多 老版本 的依赖(尤其是 numpy==1.24.3)。
pip 找不到适配 Py3.13 的二进制轮子,于是尝试从源码构建 numpy,结果在构建环境里触发了老版 setuptools/pkg_resources 对 已在 Py3.12+ 删除的 pkgutil.ImpImporter 的引用,报了这行错:
AttributeError: module ‘pkgutil’ has no attribute ‘ImpImporter’
简单说:这些固定版本不支持 Python 3.13,导致构建失败。
⸻
解决方案(两选一)
方案 A(最稳):降 Python 版本以匹配这些依赖
这些版本与 Python 3.10/3.11 最兼容。
用 conda 新建一个 Py3.11 环境
conda create -n huoshan_asr_service_py311 python=3.11 -y
conda activate huoshan_asr_service_py311
安装你的固定依赖
pip install -r requirements.txt
若你必须用 3.10:python=3.10 也可以。
方案 B:保留 Python 3.13,但升级依赖到兼容版本
需要把几个关键库升到支持 Py3.13 的版本(下面是参考区间,尽量不要再死锁到过旧版本):
示例(请按项目实际情况微调)
fastapi>=0.115
uvicorn>=0.30
websockets>=12
aiohttp>=3.10
numpy>=2.1 # 2.x 才支持更新的 Python 版本
pydantic>=2.8
python-multipart>=0.0.9
然后:
pip install -U pip setuptools wheel
pip install -r requirements.txt
⸻
为什么会这样?
• numpy==1.24.3 只提供到较早的 Python 版本的轮子;对 Py3.13 没现成轮子 → 触发源码构建。
• 源码构建时启用的构建工具链(老 setuptools/pkg_resources)用到了 已移除 的 pkgutil.ImpImporter(Py3.12 起删除)→ 直接崩。
1767

被折叠的 条评论
为什么被折叠?



