我已经使用以下命令安装了 pytorch
pip install --user torchvision
但当我尝试导入它时出现错误
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named torch
它还说所有要求都得到满足
Requirement already satisfied: torchvision in ./.local/lib/python3.6/site-packages (0.2.1)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from torchvision) (1.10.0)
Requirement already satisfied: torch in ./.local/lib/python3.6/site-packages (from torchvision) (0.4.0)
Requirement already satisfied: pillow>=4.1.1 in ./.local/lib/python3.6/site-packages (from torchvision) (5.2.0)
Requirement already satisfied: numpy in ./.local/lib/python3.6/site-packages (from torchvision) (1.14.5)
我应该怎么办?
答案1
访问火炬-PyPi。
单击“下载文件”链接。
单击“下载文件”链接将显示要下载的 torch 文件。在发布此答案时,torch 文件的名称为:torch-0.4.1.post2-cp37-cp37m-manylinux1_x86_64.whl。
打开终端并输入:
pip3 install https://files.pythonhosted.org/packages/d3/91/1b2871d6c8ca079254deae5872af32e02e9a85f07dd0834e8b3489ce138f/torch-0.4.1.post2-cp37-cp37m-manylinux1_x86_64.whl pip3 install --user torchvision
使用命令启动 Python 3 解释器
python3
,并从 python3 提示符类型输入:import torch