python - 使用 pip / Visual Studio 安装 Torch
问题描述
我正在尝试通过 Visual Studio 安装 Torch 的所有方法,但仍然出现以下错误。
关于做什么的任何建议?已经看到有人提到正常的 pip install torch 命令无法按预期工作,但是由于我对 Python 还很陌生,所以我不确定从这里去哪里。
----- Installing 'torch' -----
Collecting torch
Using cached torch-0.1.2.post2.tar.gz (128 kB)
Requirement already satisfied, skipping upgrade: pyyaml in c:\users\`\desktop\python projects\deeprl\deeprl\lib\site-packages (from torch) (5.3)
Installing collected packages: torch
Running setup.py install for torch: started
Running setup.py install for torch: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'C:\Users\`\Desktop\Python Projects\DeepRL\DeepRL\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\`\\AppData\\Local\\Temp\\pip-install-6ouq_hzc\\torch\\setup.py'"'"'; __file__='"'"'C:\\Users\\`\\AppData\\Local\\Temp\\pip-install-6ouq_hzc\\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\`\AppData\Local\Temp\pip-record-lfjewv4e\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\`\Desktop\Python Projects\DeepRL\DeepRL\include\site\python3.7\torch'
cwd: C:\Users\`\AppData\Local\Temp\pip-install-6ouq_hzc\torch\
Complete output (23 lines):
running install
running build_deps
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\`\AppData\Local\Temp\pip-install-6ouq_hzc\torch\setup.py", line 265, in <module>
description="Tensors and Dynamic neural networks in Python with strong GPU acceleration",
File "C:\Users\`\Desktop\Python Projects\DeepRL\DeepRL\lib\site-packages\setuptools\__init__.py", line 144, in setup
return distutils.core.setup(**attrs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\`\AppData\Local\Temp\pip-install-6ouq_hzc\torch\setup.py", line 99, in run
self.run_command('build_deps')
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\`\AppData\Local\Temp\pip-install-6ouq_hzc\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\`\Desktop\Python Projects\DeepRL\DeepRL\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\`\\AppData\\Local\\Temp\\pip-install-6ouq_hzc\\torch\\setup.py'"'"'; __file__='"'"'C:\\Users\\`\\AppData\\Local\\Temp\\pip-install-6ouq_hzc\\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\`\AppData\Local\Temp\pip-record-lfjewv4e\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\`\Desktop\Python Projects\DeepRL\DeepRL\include\site\python3.7\torch' Check the logs for full command output.
----- Failed to install 'torch' -----
解决方案
推荐阅读
- django - 如何在 Django 视图的模型中引用我自己的记录?
- python - 尝试使用 OR 选项搜索两个不同的 REGEX (python)
- c# - 测试 Lambda 时出错:未找到应用程序依赖项清单中指定的程序集
- php - 如何将 id 作为父级分配给下一行列作为子级
- java - Spring Boot Data JPA:与共享主键的一对一关系
- python - 如何设置 Keras Autoencoder 和 reshape() 以使用 ImageDataGenerator 处理 224 x 224 jpg 图像?
- python - 如何从 .exec_run docker-py 获取行输出流的行
- php - PHP 警告:使用未定义的常量 self - 假定为 'self'
- node.js - 如何更新 Socket.io 连接中的查询参数?
- python - 有没有办法在 Python 中生成 Firestore 类?