2

我正在尝试安装 PyTorch,但每次它都会引发相同的错误(ModuleNotFoundError: No module named 'tools.nnwrap')。

这是键入的内容:pip install torch

这是我每次得到的:

Collecting torch
Using cached https://files.pythonhosted.org/packages/f8/02/880b468bd382dc79896eaecbeb8ce95e9c4b99a24902874a2cef0b562cea/torch-0.1.2.post2.tar.gz

Requirement already satisfied: pyyaml in c:\users\user\appdata\local\programs\python\python37-32\lib\site-packages (from torch) (5.1.2)

Installing collected packages: torch

Running setup.py install for torch … error

ERROR: Command errored out with exit status 1:

command: ‘c:\users\user\appdata\local\programs\python\python37-32\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py’"’"’; file=’"’"‘C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record ‘C:\Users\User\AppData\Local\Temp\pip-record-b_c49sh\install-record.txt’ --single-version-externally-managed --compile

cwd: C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch

Complete output (23 lines):

running install

running build_deps

Traceback (most recent call last):

File “&lt;string>”, line 1, in <module>

File “C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py”, line 265, in
description=“Tensors and Dynamic neural networks in Python with strong GPU acceleration”,

File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\setuptools_init.py", line 145, in setup
return distutils.core.setup(**attrs)

File “C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\distutils\core.py”, line 148, in setup
dist.run_commands()

File “C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\distutils\dist.py”, line 966, in run_commands
self.run_command(cmd)

File “C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\distutils\dist.py”, line 985, in run_command
cmd_obj.run()

File “C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py”, line 99, in run
self.run_command(‘build_deps’)

File “C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\distutils\cmd.py”, line 313, in run_command
self.distribution.run_command(command)

File “C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\distutils\dist.py”, line 985, in run_command
cmd_obj.run()

File “C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py”, line 51, in run
from tools.nnwrap import generate_wrappers as generate_nn_wrappers

ModuleNotFoundError: No module named ‘tools.nnwrap’
----------------------------------------
ERROR: Command errored out with exit status 1: ‘c:\users\user\appdata\local\programs\python\python37-32\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py’"’"’; file=’"’"‘C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record ‘C:\Users\User\AppData\Local\Temp\pip-record-_b_c49sh\install-record.txt’ --single-version-externally-managed --compile Check the logs for full command output.

有谁知道如何解决这个错误!!

4

3 回答 3

0

建议直接从Pytorch网站-https://pytorch.org/get-started/locally/获取与系统配置匹配的所需URL

选择符合您系统配置的选项并使用 anaconda pip install the url

Pytorch pip 安装窗口

于 2020-05-02T20:21:49.200 回答
0

尝试粘贴命令

pip install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

在 Anaconda 提示中。为我工作。

于 2021-01-26T15:48:55.790 回答
0
# for OS: Windows, package: pip, Language: python3.6 (below command is valid for only mentioned python 3.6)

pip3 install https://download.pytorch.org/whl/cu90/torch-1.1.0-cp36-cp36m-win_amd64.whl
pip3 install https://download.pytorch.org/whl/cu90/torchvision-0.3.0-cp36-cp36m-win_amd64.whl

对于安装的其他版本/类型的软件(操作系统、软件包、语言),必须从以下链接生成命令:https ://pytorch.org/get-started/locally/

于 2019-11-20T14:56:37.793 回答