タイトル: [windows, uv環境でパッケージのバージョン合わせ]
はじめに
背景
windows11, cpu, python, uv環境でwhisperxで最新版をいれると動作しないことがある。versionをダウングレードする時に、間接依存パッケージとのバージョン合わせが必要。
対象読者
- uvに興味がある方
環境
| 項目 | バージョン/詳細 |
|---|---|
| OS | Windows 11 |
| 言語 | Python 3.12 |
| ライブラリ | whisperx, torch, torchaudio |
| その他 | - |
- 実施日付:2026.01.23
uv run python app.py
uv add whisperx
uv add whisperx==3.3
uv add torch==2.5.1 torchaudio==2.5.1
問題
起きたエラー
raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpo
int. (1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only`
set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source. (2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
WeightsUnpickler error: Unsupported global: GLOBAL omegaconf.listconfig.ListConfig was not an allowed global by default. Please use `torch.serialization.add_safe_g
lobals([omegaconf.listconfig.ListConfig])` or the `torch.serialization.safe_globals([omegaconf.listconfig.ListConfig])` context manager to allowlist this global if you trust this class/function.
困っている点
- コード実行エラーとなり、先に進まない。
解決方法
手順 1: [各パッケージのバージョン調査]
説明文
torch 2.6から変更があったということなのでどのようなバージョンがあるかをまず調べる。
uv はPYPIにあるパッケージのバージョンを取得する方法は不明(ない?)なのでpipで取得。
pip index versions package_name
- 実施
pip index versions torch
pip index versions torchaudio
pip index versions whisperx
手順 2: [torch, torchaudioをまず確定]
説明文
pip index versionで取得したtorch, torchaudioでバージョンを確定。そのバージョンを入れる。今回は2.5.1(torch, torchaudioは同じバージョン)を入れる。
uv add torch==2.5.1
uv add torchaudio==2.5.1
これで2つパッケージは間接依存から直接依存パッケージとして取り入れる
手順 3: [whisperxの取り入れ]
説明文
pip index versionsで取得したwhisperxのバージョンでダウングレードしながら繰り返して動作可まで確認。飛び飛びで全バージョンは確認していないが、3.3は動作するようでこれで確定。
uv add whisperx==x.x
関連のあるコード
コードを見る(クリックで展開)
import whisperx
whisperx.load_model("large-v2", "cpu", compute_type="float32")
結果
期待通りの動作
- 別の問題はまだあるようですが、とりあえず現段階では期待通り動作
この記事が役に立ったら、いいね ❤️ やストック 📚 をお願いします!
質問やコメントもお気軽にどうぞ 💬