I have successfully installed torch in my virtual environment in PyCharm (it shows up in Preferences -> Project Interpreter). However, when I try to import torch by running: “import torch” I receive the following error:
Traceback (most recent call last):
File “”, line 1, in 
File “/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/torch/init.py”, line 136, in 
from torch._C import *
File “/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
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
I have tried to copy the libc++.1.dylib file from ‎⁨Macintosh HD⁩ ▸ ⁨opt⁩ ▸ ⁨anaconda3⁩ ▸ ⁨pkgs⁩ ▸ ⁨libcxx-4.0.1-hcfea43d_1⁩ ▸ ⁨lib⁩ into the torch/lib folder, which removes that error, but gives me the following one:
Traceback (most recent call last):
File “”, line 1, in 
File “/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/knaess/Documents/coding/mouth_detection/venv/lib/python3.8/site-packages/torch/init.py”, line 138, in 
all += [name for name in dir(_C)
NameError: name ‘_C’ is not defined
How can i fix this?