You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python 3.13安装openai-whisper报错KeyError: '__version__'求助

解决Python 3.13安装openai-whisper时的KeyError: 'version'问题

问题场景

在Python 3.13环境中安装openai-whisper时触发KeyError: '__version__'错误,即使降级Python版本也无法解决,具体报错如下:

Collecting openai-whisper
  Using cached openai-whisper-20240930.tar.gz (800 kB)
  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/pinjalim/Dropbox/Projects/Transcripto/.venv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/pinjalim/Dropbox/Projects/Transcripto/.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/pinjalim/Dropbox/Projects/Transcripto/.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/q5/r66rvlp92fn06jqmhpg3zbwm0000gn/T/pip-build-env-jhoypdd0/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/q5/r66rvlp92fn06jqmhpg3zbwm0000gn/T/pip-build-env-jhoypdd0/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 303, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/q5/r66rvlp92fn06jqmhpg3zbwm0000gn/T/pip-build-env-jhoypdd0/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/q5/r66rvlp92fn06jqmhpg3zbwm0000gn/T/pip-build-env-jhoypdd0/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.

解决方案

这个错误源于whisper源码包的版本读取逻辑与新版Python/setuptools不兼容,以下是几种可行的解决方法:

  • 安装预编译wheel包:跳过源码构建,直接安装预编译的二进制包,执行命令:

    pip install --only-binary :all: openai-whisper
    
  • 升级pip和setuptools:确保依赖管理工具是最新版本,避免兼容性问题:

    pip install --upgrade pip setuptools
    

    升级后再尝试重新安装openai-whisper。

  • 直接从GitHub仓库安装:克隆最新源码并本地安装,绕开PyPI包的版本读取问题:

    git clone https://github.com/openai/whisper.git
    cd whisper
    pip install .
    
  • 创建干净的虚拟环境:如果当前虚拟环境存在旧依赖干扰,重新创建环境后再安装:

    # 创建新虚拟环境
    python3.13 -m venv whisper_env
    # 激活环境(Mac/Linux)
    source whisper_env/bin/activate
    # Windows环境激活命令:whisper_env\Scripts\activate
    # 安装whisper
    pip install openai-whisper
    

内容的提问来源于stack exchange,提问作者user9889742

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 08:40:58