Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import PySpin in Conda: fails to find mkl_intel_thread.dll

I'm using the PySpin api for a Point Grey camera in Anaconda. The api is a Python wrapper for a C++ library called Spinnaker (https://www.ptgrey.com/spinnaker-sdk).

When I import within Spyder (import PySpin), things work fine (note I start Spyder from the Conda prompt in the environment where everything is installed). Unfortunately running the import from the conda prompt instead of Spyder (python foo.py where foo.py contains import PySpin) yields:

Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll.

The ordinal 242 could not be located in the dynamic link library C:\Anaconda3\Library\bin\mkl_intel_thread.dll

Note I installed Spinnaker (PySpin) from a wheel at the anaconda prompt:

pip install spinnaker_python-1.20.0.15-cp36-cp36m-win_amd64.whl

A bunch of places online it says to find the following files in C:\Windows\System32 and rename them or delete them:

mkl_core.dll
mkl_def.dll
mkl_intel_thread.dll

Those files are not present on my machine, so that seems to not be the problem in my case.

For instance here they mention that solution:
The ordinal 242 could not be located in the dynamic link library Anaconda3\Library\bin\mkl_intel_thread.dll

like image 887
eric Avatar asked Apr 21 '19 22:04

eric


2 Answers

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

import numpy as np # must be imported first
import PySpin

system = 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.

like image 91
adamp87 Avatar answered Sep 19 '22 19:09

adamp87


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
like image 25
Tomi Avatar answered Sep 21 '22 19:09

Tomi