首页 > 解决方案 > 使用 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' -----

标签: pythonpipinstallationpytorchtorch

解决方案


推荐阅读