Python找不到火炬

时间:2020-03-26 08:17:00

标签: python pytorch python-module

我要使用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就像是一种魅力

关于我能做什么的任何想法?

存储库说:

火炬(作为火炬或通过https://pytorch.org/get-started/locally/安装)

1 个答案:

答案 0 :(得分:0)

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

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

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