#3962 ModuleNotFoundError: No module named 'torch'

103.172* Posted at: 2 hours ago 👁7

Traceback (most recent call last):
File "D:\python\pyvideotrans\pyvideotrans\videotrans\mainwin\_actions_sub.py", line 138, in check_cuda

import torch

ModuleNotFoundError: No module named 'torch'


=
system:Windows-10-10.0.26200-SP0
version:v3.84
frozen:False
language:zh
root_dir:D:/python/pyvideotrans/pyvideotrans
Python: 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]

1 Replies

这是由于Python环境中缺少PyTorch库导致的。软件在启动时尝试检查CUDA加速环境,但未能导入必需的torch模块。

解决方案:

  1. 请确保您是通过源码部署运行,而非Windows预打包版。预打包版应已包含所有依赖,不应出现此错误。
  2. 如果您是源码运行,请使用uv包管理器在项目根目录下重新同步依赖:

    uv sync
  3. 如果上述命令无效,可以尝试手动安装PyTorch(请确保CUDA版本为12.8):

    uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
  4. 安装完成后,重新启动软件。

请注意:

  • 此错误通常出现在源码部署环境。如果您使用的是Windows预打包版(.exe),请重新下载完整软件包并解压到非系统盘、无中文的路径下运行。
  • 确保您的Python版本为3.10。

请查阅相关文档:

Post Your Reply
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update.

Related resource