LoginSignup
0

More than 3 years have passed since last update.

Macでtorchvisionをインストールしたらimport torchができなくなった

Posted at

torchvision(0.6.0)をインストールしたらtorchのバージョンが1.4.0から1.5.0にアップデートされてエラーが出るようになった.

    import torch
  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

解決策
libc++.1.dylibは/usr/libの下にあったため,install_name_toolを使って解決する.

install_name_tool -add_rpath /usr/lib /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/torch/_C.cpython-38-darwin.so

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
0