【问题标题】:ModuleNotFoundError: No module named ‘tools.nnwrap’ (windows)ModuleNotFoundError:没有名为“tools.nnwrap”的模块(Windows)
【发布时间】:2020-03-16 07:48:14
【问题描述】:

我正在尝试安装 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 “<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.

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

【问题讨论】:

  • 请尝试officially recommended command:pip3 install torch==1.3.1+cpu torchvision==0.4.2+cpu -f https://download.pytorch.org/whl/torch_stable.html(或选择启用cuda的版本之一)
  • 查看链接:download.pytorch.org/whl/torch_stable.html 错误:找不到满足要求的版本 torch==1.3.1+cu92(来自版本:0.1.2、0.1.2.post1、0.1。 2.post2) 错误:没有找到匹配的分布为 torch==1.3.1+cu92(它仍然没有工作)
  • 您是否使用了上面的确切命令(包括-f 部分)?你运行的是 32 位还是 64 位的 python?

标签: python machine-learning pip pytorch torchvision


【解决方案1】:
# 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/

【讨论】:

  • 错误:torch-1.1.0-cp36-cp36m-win_amd64.whl 不是该平台支持的滚轮。 (两个命令的错误相同)
  • 您使用的操作系统以及 python 版本。您是否有机会使用 conda ?
  • windows 10 64 位,python 3.7.5 32 位(无 conda)
  • pip3 install torch==1.3.1+cpu torchvision==0.4.2+cpu -f https://download.pytorch.org/whl/torch_stable.html
【解决方案2】:

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

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

【讨论】:

    【解决方案3】:

    尝试粘贴命令

    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 提示中。为我工作。

    【讨论】:

      猜你喜欢
      • 2019-11-13
      • 2023-03-03
      • 2020-11-30
      • 1970-01-01
      • 1970-01-01
      • 2020-11-20
      • 2019-03-28
      • 1970-01-01
      • 2022-01-07
      相关资源
      最近更新 更多