我正在尝试使用 python zincbase,需要在 Windows 上安装 pytorch。执行时
pip install torch
我收到一条错误消息
ERROR: Command errored out with exit status 1:
command: 'c:\data-nobackup\development\im-099329-
gremlintest\env\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\104172\\AppData\\Local\\Temp\\pip-install-5go0i_r_\\torch\\setup.py'"'"'; __file__='"'"'C:\\Users\\104172\\AppData\\Local\\Temp\\pip-install-5go0i_r_\\torch\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\104172\AppData\Local\Temp\pip-wheel-bk0m_2ck' --python-tag cp36
cwd: C:\Users\104172\AppData\Local\Temp\pip-install-5go0i_r_\torch\
Complete output (30 lines):
running bdist_wheel
running build
running build_deps
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\104172\AppData\Local\Temp\pip-install-5go0i_r_\torch\setup.py", line 265, in <module>
description="Tensors and Dynamic neural networks in Python with strong GPU acceleration",
File "c:\data-nobackup\development\im-099329-gremlintest\env\lib\site-packages\setuptools\__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "c:\customsoftware\python3.6\Lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "c:\customsoftware\python3.6\Lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "c:\customsoftware\python3.6\Lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "c:\data-nobackup\development\im-099329-gremlintest\env\lib\site-packages\wheel\bdist_wheel.py", line 192, in run
self.run_command('build')
File "c:\customsoftware\python3.6\Lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\customsoftware\python3.6\Lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "c:\customsoftware\python3.6\Lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "c:\customsoftware\python3.6\Lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\customsoftware\python3.6\Lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\104172\AppData\Local\Temp\pip-install-5go0i_r_\torch\setup.py", line 51, in run
from tools.nnwrap import generate_wrappers as generate_nn_wrappers
ModuleNotFoundError: No module named 'tools.nnwrap'
ERROR: Failed building wheel for torch
我如何安装 pytorch?
答案1
你可以直接访问 PyTorch 网站:pytorch.org
然后进入“开始”页面。您将看到一个有趣的在线工具,您可以在其中选择不同的选项,它将提供安装“torch”的正确命令。
就像下面这张图一样:
正如您通过上述选择所看到的,torch 安装的命令将是以下命令:
pip3 install torch==1.3.1+cpu torchvision==0.4.2+cpu -f https://download.pytorch.org/whl/torch_stable.html
答案2
与其他库不同,我们不能仅使用 pip install torch 命令在本地安装 PyTorch。
去https://pytorch.org网站并选择您的机器和环境,它将为您提供运行的命令,如下所示 -
pip3 install torch===1.2.0 torchvision===0.4.0 -f https://download.pytorch.org/whl/torch_stable.html
对于 Python 3.7 -
pip3 install https://download.pytorch.org/whl/cpu/torch-1.0.1-cp37-cp37m-win_amd64.whl
pip3 install torchvision