Python 找不到手电筒

Python not finding torch

我想使用 deepsaber。 为此,我必须安装 Torch。

我使用 pip install torch torchvision.

做到了这一点

在运行cd scripts/generation./script_generate.sh [path to song]python之后告诉我:

Traceback (most recent call last):
  File "generate_stage1.py", line 16, in <module>
    from models import create_model
  File "/home/server/deepsaber/models/__init__.py", line 2, in <module>
    from .base_model import BaseModel
  File "/home/server/deepsaber/models/base_model.py", line 2, in <module>
    import torch
ModuleNotFoundError: No module named 'torch'
Traceback (most recent call last):
  File "generate_stage2.py", line 16, in <module>
    from models import create_model
  File "/home/server/deepsaber/models/__init__.py", line 2, in <module>
    from .base_model import BaseModel
  File "/home/server/deepsaber/models/base_model.py", line 2, in <module>
    import torch
ModuleNotFoundError: No module named 'torch'

使用 import torch 在使用 python

时效果很好

我能做什么有什么想法吗?

回购协议说:

pytorch (installed as torch or via https://pytorch.org/get-started/locally/)

很可能您安装 torch 使用 Python 2,而 script_generate.sh 使用 Python 3(参见 here):

# [...]
py=python3
# [...]

尝试 运行 pip3 install torch torchvisionpython3 -m pip install torch torchvision。另外,检查 import torch 在使用 python3 时是否有效。