为什么导入 torch for PyTorch stable(1.5) 会在 macOS 上出现错误?

问题描述 投票:0回答:1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/torch/__init__.py", line 136, in <module>
    from torch._C import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/torch/_C.cpython-38-darwin.so, 2): Library not loaded: @rpath/libc++.1.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/torch/_C.cpython-38-darwin.so
  Reason: image not found
macos import pytorch torch
1个回答
0
投票
cp /usr/lib/libc++.1.dylib /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.7/site-packages/torch/lib/

将libc++.1.dylib复制到LibraryFrameworksPython.frameworkVersions3.8libpython3.7site-packagestorch的lib文件夹中。

这样一来,问题就解决了

© www.soinside.com 2019 - 2024. All rights reserved.