PyTorch installation issues on MacOS through Anaconda
I am trying to install PyTorch on my Macbook Pro. I had no issues installing NumPy or Matplotlib using the following commands:
conda install numpy
conda install matplotlib

When I then import those into Python console, they work correctly. However, when I try to import PyTorch I get the following error:
(myenv) $ % python
Python 3.9.1 (default, Dec 11 2020, 06:28:49) 
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import torch
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;/Users/jeasl/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/torch/__init__.py&quot;, line 189, in &lt;module&gt;
    _load_global_deps()
  File &quot;/Users/jeasl/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/torch/__init__.py&quot;, line 142, in _load_global_deps
    ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
  File &quot;/Users/jeasl/opt/anaconda3/envs/myenv/lib/python3.9/ctypes/__init__.py&quot;, line 382, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Users/jeasl/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/torch/lib/libtorch_global_deps.dylib, 10): Library not loaded: @rpath/libomp.dylib
  Referenced from: /Users/jeasl/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/torch/lib/libtorch_global_deps.dylib
  Reason: image not found

I have absolutely no idea what is causing this, even after looking through several forums for answers. When I got to try and reinstall PyTorch, I get this:
(myenv) $ % conda install pytorch
Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

So it seems like it is all downloaded correctly - I just can't import it when in the Python console.
Any idea how to get this working correctly?

OP indicates use of Python 3.9 from Anaconda, but the PyTorch installer tool explicitly notes that one must use Python from the Conda Forge channel:

I have no issue with the following environment YAML:
File: pytorch.yaml
channels:
  - pytorch
  - conda-forge
  - defaults
dependencies:
  - python=3.9
  - pytorch
  - torchvision
  - torchaudio
  - numpy
  - matplotlib

created with
conda env create -f pytorch.yaml -n foo

