无法安装pytorch-ModuleNotFoundError:没有名为“ tools.nnwrap”的模块

时间:2020-08-10 17:34:06

标签: python python-3.x installation pip pytorch

我无法在python 3.7上安装PyTorch。其他人也会发生此错误,但建议的修复程序不起作用。我曾尝试安装车轮和导入工具,但均无济于事。

错误:ModuleNotFoundError: No module named 'tools.nnwrap'

运行命令pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html

完整输出:Looking in links: https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html Collecting torch Using cached torch-0.1.2.post2.tar.gz (128 kB) Collecting torchvision Using cached torchvision-0.2.2.post3-py2.py3-none-any.whl (64 kB) Requirement already satisfied: pyyaml in c:\users\lv7682\documents\repos\security_patch\spms\webapp\securitypatchmanagementsystem\venv\venv\lib\site-packages (from torch) (5.3.1) Collecting pillow>=4.1.1 Using cached Pillow-7.2.0-cp37-cp37m-win32.whl (1.8 MB) Collecting numpy Using cached numpy-1.19.1-cp37-cp37m-win32.whl (10.9 MB) Collecting six Using cached six-1.15.0-py2.py3-none-any.whl (10 kB) Using legacy 'setup.py install' for torch, since package 'wheel' is not installed. Installing collected packages: torch, pillow, numpy, six, torchvision Running setup.py install for torch ... error ERROR: Command errored out with exit status 1: command: 'c:\users\lv7682\documents\repos\security_patch\spms\webapp\securitypatchmanagementsystem\venv\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[ 0] = '"'"'C:\\Users\\LV7682\\AppData\\Local\\Temp\\pip-install-4b80gt33\\torch\\setup.py'"'"'; __file__='"'"'C:\\Users\\LV7682\\AppData\\Local\\Temp\\pip-install-4b80gt33\\torch\\setup .py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --reco rd 'C:\Users\LV7682\AppData\Local\Temp\pip-record-z5_fy7cc\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\lv7682\documents\repos\security _patch\spms\webapp\securitypatchmanagementsystem\venv\venv\include\site\python3.7\torch' cwd: C:\Users\LV7682\AppData\Local\Temp\pip-install-4b80gt33\torch\ Complete output (23 lines): running install running build_deps Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\LV7682\AppData\Local\Temp\pip-install-4b80gt33\torch\setup.py", line 265, in <module> description="Tensors and Dynamic neural networks in Python with strong GPU acceleration", File "c:\users\lv7682\documents\repos\security_patch\spms\webapp\securitypatchmanagementsystem\venv\venv\lib\site-packages\setuptools\__init__.py", line 163, in setup return distutils.core.setup(**attrs) File "C:\Users\LV7682\AppData\Local\Programs\Python\Python37-32\lib\distutils\core.py", line 148, in setup dist.run_commands() File "C:\Users\LV7682\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 966, in run_commands self.run_command(cmd) File "C:\Users\LV7682\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "C:\Users\LV7682\AppData\Local\Temp\pip-install-4b80gt33\torch\setup.py", line 99, in run self.run_command('build_deps') File "C:\Users\LV7682\AppData\Local\Programs\Python\Python37-32\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "C:\Users\LV7682\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "C:\Users\LV7682\AppData\Local\Temp\pip-install-4b80gt33\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\lv7682\documents\repos\security_patch\spms\webapp\securitypatchmanagementsystem\venv\venv\scripts\python.exe' -u -c 'import sys , setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\LV7682\\AppData\\Local\\Temp\\pip-install-4b80gt33\\torch\\setup.py'"'"'; __file__='"'"'C:\\Users\\LV7682\\AppData\\Local\\Temp\\p ip-install-4b80gt33\\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\LV7682\AppData\Local\Temp\pip-record-z5_fy7cc\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\user s\lv7682\documents\repos\security_patch\spms\webapp\securitypatchmanagementsystem\venv\venv\include\site\python3.7\torch' Check the logs for full command output.

1 个答案:

答案 0 :(得分:0)

已修复:需要使用python 64位而非32位