Cannot import torch - Image not found
I'm trying to import torch but failed because of Image not Found error. Here is the error when I entered import torch: 

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
 in 
----&gt; 1 import torch

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/torch/__init__.py in 
    134     # See Note [Global dependencies]
    135     _load_global_deps()
--&gt; 136     from torch._C import *
    137 
    138 __all__ += [name for name in dir(_C)

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


Thank you very much!

EDIT: This works for me: 

&gt;&gt;&gt; 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


I solved this by doing this way, suppose you are using the virtual environment.
Replace YOUR_PATH_TO_PYTHON_ENV with your python environment path.

install_name_tool -add_rpath /usr/lib YOUR_PATH_TO_PYTHON_ENV/venv/lib/python3.8/site-packages/torch/_C.cpython-38-darwin.so


If you are using your local python, maybe it will look like.

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


Basically, you need to add rpath of your library to torch in your python environment.
