Import PySpin in Conda: fails to find mkl_intel_thread.dll Import PySpin in Conda: fails to find mkl_intel_thread.dll python-3.x python-3.x

Import PySpin in Conda: fails to find mkl_intel_thread.dll


When I first import numpy and the import PySpin, then it works for me.

import numpy as np # must be imported firstimport PySpinsystem = PySpin.System.GetInstance()version = system.GetLibraryVersion()print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build))# Library version: 1.20.0.15

I am using Python 3.5 under Windows 10 with Miniconda.


The issue is caused by file libiomp5md.dll included in the spinnaker_python wheel being incompatible with Anaconda distribution. Simply removing or renaming this file will result the default Anaconda version of the file to be loaded instead.

Execute the following command from the Anaconda prompt to fix the issue. If Anaconda is installed for all users, you need Administrator version of Anaconda prompt.

move %CONDA_PREFIX%\Lib\site-packages\PySpin\libiomp5md.dll %CONDA_PREFIX%\Lib\site-packages\PySpin\libiomp5md.bak


Solution recommended by Point Grey

From the developers at Point Grey, who I emailed about this issue and they were aware of it. They suggested removing the numpy that is installed with conda and reinstall it with pip. That is:

conda uninstall numpypip install numpy

Note while this worked, I can't guarantee it will scale well within complex projects that include other dependencies.

Update: this worked for a day or so, but in my hands it stopped working when I added other dependencies/updates (in particular OpenCV). However, maybe other people will have better luck with this solution so I'll leave it here.


Second Solution

If you are having trouble with the other solutions, maybe give this a shot it worked for me: run the code from ipython launched from the conda prompt, and then run from conda again:

ipythyon%run foo.py  #script containing import PySpinexit()

It worked there, which is not surprising (this is basically what Spyder does). Strangely, back in the conda prompt I tried running the program again:

python foo.py

And this time it worked. So, it was not working before I did it in ipython, and now it is working.

Frankly I have no idea why this fixed the problem, but it did. \_(ツ)_/

I'm leaving these solutions here, but frankly I would try importing numpy before PySpin, as in the accepted answer. It's just easier and less disruptive.