无法在PyCharm中安装PyTorch(Python 3.9 / macOS)

奥马尔·阿尔苏威迪

环境:

  • 点子版本:20.2.4
  • 解释器:Python 3.9.0
  • 操作系统:macOS Big Sur
  • 其他一切也都是最新的

我在终端中尝试了以下命令,但没有一个起作用:

  • 点安装火炬
  • pip3安装割炬
  • 点安装火炬torchvision torchaudio

对于每个命令,我都会收到不同的错误消息,但这是“ pip install torch”的输出:

Collecting torch
  Using cached torch-0.1.2.post2.tar.gz (128 kB)
Requirement already satisfied: pyyaml in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from torch) (5.3.1)
Using legacy 'setup.py install' for torch, since package 'wheel' is not installed.
Installing collected packages: torch
    Running setup.py install for torch: started
    Running setup.py install for torch: finished with status 'error'

DEPRECATION: The -b/--build/--build-dir/--build-directory option is deprecated. pip 20.3 will remove support for this functionality. A possible replacement is use the TMPDIR/TEMP/TMP environment variable, possibly combined with --no-clean. You can find discussion regarding this at https://github.com/pypa/pip/issues/8333.
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/jz/bbl56kxj3tl_wssc22lnxqmc0000gn/T/pycharm-packaging/torch/setup.py'"'"'; __file__='"'"'/private/var/folders/jz/bbl56kxj3tl_wssc22lnxqmc0000gn/T/pycharm-packaging/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 /private/var/folders/jz/bbl56kxj3tl_wssc22lnxqmc0000gn/T/pip-record-92u0tiue/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/torch
         cwd: /private/var/folders/jz/bbl56kxj3tl_wssc22lnxqmc0000gn/T/pycharm-packaging/torch/
    Complete output (23 lines):
    running install
    running build_deps
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/jz/bbl56kxj3tl_wssc22lnxqmc0000gn/T/pycharm-packaging/torch/setup.py", line 225, in <module>
        setup(name="torch", version="0.1.2.post2",
      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/private/var/folders/jz/bbl56kxj3tl_wssc22lnxqmc0000gn/T/pycharm-packaging/torch/setup.py", line 99, in run
        self.run_command('build_deps')
      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/private/var/folders/jz/bbl56kxj3tl_wssc22lnxqmc0000gn/T/pycharm-packaging/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: /usr/local/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/jz/bbl56kxj3tl_wssc22lnxqmc0000gn/T/pycharm-packaging/torch/setup.py'"'"'; __file__='"'"'/private/var/folders/jz/bbl56kxj3tl_wssc22lnxqmc0000gn/T/pycharm-packaging/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 /private/var/folders/jz/bbl56kxj3tl_wssc22lnxqmc0000gn/T/pip-record-92u0tiue/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/torch Check the logs for full command output.
奥马尔·阿尔苏威迪

好的,我通过使用conda软件包管理器而不是pip来解决此问题。Conda使用python版本3.8.5,而版本3.9用于我的pip管理器。我不太确定不兼容的问题是由于pip本身引起的,还是由于它使用的是python版本3.9。无论如何,在下载图形macOS安装程序之后:

conda install pytorch torchvision torchaudio -c pytorch

这样就可以成功安装PyTorch!

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

无法在macOS中卸载python3

来自分类Dev

无法在MacOS Sierra上使用pip3安装mysqlclient

来自分类Dev

无法为Pycharm(MacOs)安装Jade插件

来自分类Dev

无法安装Pycharm(MacOs)的Jade插件

来自分类Dev

无法在macOS Catalina 10.15.4上安装bsddb3 Python软件包

来自分类Dev

在macOS上为Python3安装NumPy时出错

来自分类Dev

在MacOS X上为Python 3安装Aspell

来自分类Dev

macOS控制台Vim Python3安装

来自分类Dev

Tkinter Python 3在MacOS上的缩放问题

来自分类Dev

macOS Sierra中Spyder 3的问题

来自分类Dev

无法在 MacOs 中为 python2 安装 pyopenssl

来自分类Dev

Sublime Text 3无法在macOS Mojave上打开

来自分类Dev

macOS Hight Sierra 上的 Gradle - Java 9

来自分类Dev

清理 MacOS Python 安装

来自分类Dev

无法在MacOS 10.8.4中安装lxml

来自分类Dev

在MacOS 11.0中无法使用“ pod安装”

来自分类Dev

MacOS上的Python3,gcc和clang

来自分类Dev

Python 3从计算机上消失-MacOS

来自分类Dev

恢复MacOS系统的Python3版本

来自分类Dev

brew python3 突然停止在 MacOs 上工作

来自分类Dev

debian9无法使用pip3安装python软件包或使用apt卸载软件包

来自分类Dev

无法在MacOS上安装mysqlclient

来自分类Dev

macOS-无法安装dlib

来自分类Dev

NTFS-3G无法在macOS Catalina上运行:MFTMirr与$ MFT不匹配(记录3)

来自分类Dev

PyCharm:在 macOS 上找不到 Anaconda 安装

来自分类Dev

无法在Debian 9中安装Linux Respin

来自分类Dev

在MacOS X中安装valgrind

来自分类Dev

在IE9中复制CSS3动画

来自分类Dev

引导程序3 .nav在Internet Explorer 9中的位置