Installation problem: Library not loaded: @rpath/libc++.1.dylib

I installed pytorch successfully on my Mac (Sierra 10.12.6), using pip install --user torch==1.0.0. However, when I try to import torch from inside python (2.7.10), I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/username/Library/Python/2.7/lib/python/site-packages/torch/", line 84, in <module>
    from torch._C import *
ImportError: dlopen(/Users/username/Library/Python/2.7/lib/python/site-packages/torch/, 9): Library not loaded: @rpath/libc++.1.dylib
  Referenced from: /Users/username/Library/Python/2.7/lib/python/site-packages/torch/
  Reason: image not found

I know of at least one other user who has had exactly the same problem, but on the Mojave os, for the same versions of python and torch. Previously, I was able to run torch 0.4.1 without incident, this problem is only post-upgrade. I am able to run torch 1.0.0 with python 3.6.5 (within a virtualenv) fine.

Hey, have you got this fixed? I got same situation like you.

No. I didn’t get any clarity on this specific issue, but I was able to reinstall successfully from source.

I fixed it by adding /usr/lib to rpath using install_name_tool.

install_name_tool -add_rpath /usr/lib ~/Library/Python/2.7/lib/python/site-packages/torch/

thanks, this helps me to solve the same problem.
just use “install_name_tool -add_rpath xxx/”

Thanks! I installed torch globally. I fixed the issue with
sudo install_name_tool -add_rpath /usr/lib /Library/Python/2.7/lib/python/site-packages/torch/