Failed to load image Python extension: Could not find module


I am getting something similar:

UserWarning: Failed to load image Python extension: dlopen(/Users/anderson/Library/Caches/pypoetry/virtualenvs/redacted-cMHZGf73-py3.9/lib/python3.9/site-packages/torchvision/, 0x0006): Library not loaded: @rpath/libpng16.16.dylib
  Referenced from: /Users/anderson/Library/Caches/pypoetry/virtualenvs/redacted-cMHZGf73-py3.9/lib/python3.9/site-packages/torchvision/
  Reason: tried: '/Users/malfet/miniforge3/envs/py_39_torch-1.10.2/lib/libpng16.16.dylib' (no such file), '/Users/malfet/miniforge3/envs/py_39_torch-1.10.2/lib/libpng16.16.dylib' (no such file), '/Users/malfet/miniforge3/envs/py_39_torch-1.10.2/lib/libpng16.16.dylib' (no such file), '/Users/malfet/miniforge3/envs/py_39_torch-1.10.2/lib/libpng16.16.dylib' (no such file), '/usr/local/lib/libpng16.16.dylib' (no such file), '/usr/lib/libpng16.16.dylib' (no such file)
  warn(f"Failed to load image Python extension: {e}")

Seems like the file is not being included in torchvision-0.11.3-cp39-cp39-macosx_11_0_arm64.whl and we are not pointing to the right location anyway. I don’t have miniforge installed or a malfet user.

Hi Andersen!
I have 100% similar warning on MBP 14 m1 pro.
Do you know how to fix this warn? Internet doesn’t know same problems and I don’t know how to fix it.

Same here with Macbook 16" M1Pro and python 3.8.9

Getting the issue on Linux with torchvision nightly CPU (no CUDA) installed via:

conda install -c pytorch-nightly torchvision cpuonly

UserWarning: Failed to load image Python extension: /home/azureuser/miniconda3/envs/pytorch-0/lib/python3.9/site-packages/torchvision/ undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs

Demangling the symbol name, it becomes torch::jit::parseSchemaOrName(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)

Should I file a GitHub issue?

Hi Andrade, have you fixed it? I have the same problem.
There is a closed issue at where malfet said it has been resolved by 0.11.3, but I doubt that.
I create an issue at

I solved it by installing libpng and libjpeg with Homebrew and manually adding symlinks to /usr/local/lib.

I still think we should address this with a ticket since PyTorch packages are supposed to come with all dependencies included.

The same situation I encountered, I 'd like to wonder whether you have solved this error, plz.

Hope everything is fine on your side :slight_smile:
I just upgraded my CUDA from 10.2 to 11.1 and everything worked.

I encountered the same problem and fixed it by going to the directory that is shown in the error. It opens up a .txt file and you just need to change the extension name of “”. In my case, I had to change it to “image.jpg” since i am using jpg files for my code. Try it! hope it will help.

I’m getting this in a ubuntu docker image with 1.11, “pip3 install torch torchvision torchaudio --extra-index-url

I am having the same issue. I am installing from source in an ubuntu docker image with cuda 11.6. Torchvision v0.12.0

My issue was solved with conda install libpng jpeg

1 Like

On Apple M1Pro with latest pytorch nightly, this solved my issue

Same import warning here after building latest version from source on Ubuntu 20.04 (WSL2) Virtualenv with Intel CPU and Nvidia Turing.