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

MacOS本地运行Whisper CLI报错求助:NotADirectoryError问题

本地运行Whisper报错求助

问题描述

尝试在本地终端运行Whisper时持续报错,已按官方仓库说明安装pytorch、ffmpeg等所有依赖,恳请提供解决思路。

操作步骤

  • 切换至确认可用的Python版本:pyenv shell 3.9.9
  • 执行命令:whisper test.mp3,触发如下错误:
Traceback (most recent call last):
  File "/usr/local/bin/whisper", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/Cellar/openai-whisper/20231117/libexec/lib/python3.11/site-packages/whisper/transcribe.py", line 458, in cli
    model = load_model(model_name, device=device, download_root=model_dir)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/openai-whisper/20231117/libexec/lib/python3.11/site-packages/whisper/__init__.py", line 133, in load_model
    checkpoint_file = _download(_MODELS[name], download_root, in_memory)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/openai-whisper/20231117/libexec/lib/python3.11/site-packages/whisper/__init__.py", line 51, in _download
    os.makedirs(root, exist_ok=True)
  File "<frozen os>", line 225, in makedirs
NotADirectoryError: [Errno 20] Not a directory: '/Users/caleb/.cache/whisper'

设备环境

  • 2019款Intel MacBook Pro,系统Sonoma 14.1.2
  • 使用iTerm搭配ZShell
  • 通过PyEnv管理Python版本,可用版本:3.9.9、3.10.10、3.11.4、3.11.7、3.12.1

已尝试的解决方法

  • 以多种方式重装Python及所有依赖
  • 重启Shell

可行解决思路

  1. 修正缓存路径类型:错误提示/Users/caleb/.cache/whisper不是目录,先检查该路径的类型:
    ls -ld /Users/caleb/.cache/whisper
    
    如果输出显示为文件,执行以下命令删除文件并创建目录:
    rm /Users/caleb/.cache/whisper
    mkdir -p /Users/caleb/.cache/whisper
    
  2. 确认目录权限:确保当前用户对缓存目录有读写权限:
    chmod -R 755 /Users/caleb/.cache
    
  3. 手动指定模型下载目录:运行Whisper时绕过默认缓存路径,手动指定模型存储目录:
    whisper test.mp3 --model-dir ~/whisper-models
    
  4. 对齐Python环境与Whisper安装:报错显示Whisper安装在Python3.11的环境中,但当前使用的是Python3.9.9,存在环境不匹配问题。建议用PyEnv创建虚拟环境重新安装:
    pyenv shell 3.9.9
    python -m venv whisper-env
    source whisper-env/bin/activate
    pip install openai-whisper ffmpeg-python torch
    
    激活虚拟环境后再执行whisper test.mp3

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 09:07:09