pytorch dlopen image not found mac

一个安装问题

1
2
3
4
5
6
7
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/username/Library/Python/3.8/lib/python3.8/site-packages/torch/__init__.py", line 84, in <module>
from torch._C import *
ImportError: dlopen(/Users/username/Library/Python/3.8/lib/python3.8/site-packages/torch/_C.cpython-38-darwin.so, 9): Library not loaded: @rpath/libc++.1.dylib
Referenced from: /Users/username/Library/Python/3.8/lib/python3.8/site-packages/torch/_C.cpython-38-darwin.so
Reason: image not found

安装运行pytorch之后报了一个上面的错,找了很多方法,最后找到结果,参考:
https://discuss.pytorch.org/t/installation-problem-library-not-loaded-rpath-libc-1-dylib/36802

以下的so换成你自己的路径

1
sudo install_name_tool -add_rpath /usr/lib /Users/username/Library/Python/3.8/lib/python3.8/site-packages/torch/_C.cpython-38-darwin.so

对我是有效的。

坚持原创分享,您的支持将鼓励我继续创作!