安装openai-whisper遇subprocess-exited-with-error错误求助
解决安装openai-whisper==20240930时出现KeyError: 'version'的问题
问题场景
我正在开发一个视频生成自动化项目,计划用openai-whisper实现字幕生成功能,项目依赖如下:
# File for dependencies requests == 2.32.3 gTTS == 2.5.3 openai-whisper == 20240930
执行命令 pip3 install openai-whisper 时触发错误,核心报错为 KeyError: '__version__',完整错误输出如下:
pip3 install openai-whisper ─╯ Collecting openai-whisper Downloading openai-whisper-20240930.tar.gz (800 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 800.5/800.5 kB 10.2 MB/s eta 0:00:00 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 ╰─> [25 lines of output] <string>:5: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html Traceback (most recent call last): File "/Users/ksukshavasi/redditStories/.venv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module> main() File "/Users/ksukshavasi/redditStories/.venv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/Users/ksukshavasi/redditStories/.venv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel return hook(config_settings) File "/private/var/folders/4c/kcl8fxts5w33ljgzkm5jlwww0000gn/T/pip-build-env-rqz9lofh/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=[]) File "/private/var/folders/4c/kcl8fxts5w33ljgzkm5jlwww0000gn/T/pip-build-env-rqz9lofh/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 303, in _get_build_requires self.run_setup() File "/private/var/folders/4c/kcl8fxts5w33ljgzkm5jlwww0000gn/T/pip-build-env-rqz9lofh/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 521, in run_setup super().run_setup(setup_script=setup_script) File "/private/var/folders/4c/kcl8fxts5w33ljgzkm5jlwww0000gn/T/pip-build-env-rqz9lofh/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 319, in run_setup exec(code, locals()) File "<string>", line 21, in <module> File "<string>", line 11, in read_version KeyError: '__version__' [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.
环境信息:Python 3.13虚拟环境,pip 24.3.1,安装其他包(如pytest)正常。
解决方案
1. 降级Python版本到3.12及以下
openai-whisper 20240930版本的构建脚本未适配Python 3.13特性,导致版本读取逻辑出错。切换到Python 3.12或更低版本的虚拟环境后,重新执行安装命令:
pip3 install openai-whisper==20240930
2. 安装whisper的最新兼容版本
若需保留Python 3.13,可安装官方已修复适配的最新版本:
pip3 install --upgrade openai-whisper
3. 从GitHub仓库直接安装开发版(备选)
如果上述方法无效,可尝试安装仓库最新代码(注意:开发版可能存在不稳定情况):
pip3 install git+https://github.com/openai/whisper.git
内容的提问来源于stack exchange,提问作者Kashyap Sukshavasi
相关产品推荐
相关产品推荐

