Touble with numpy (import)

Hello, I have been using Python with Capella for some time, and this forum is often very useful to me.
Today I’m facing a problem that I can’t solve. I use Capella with Anaconda’s python interpreter. Unfortunately, what works in Spyder (anaconda) doesn’t work in Capella. The numpy library cannot be imported: an error is raised.

I’m not familiar with the forums, so forgive me if my question isn’t clear.

Here is the simple program that shows the problem:

import pandas as pd
print(pd.Series([1, 3, 5, 0, 6, 8]))

Result in spyder → OK:

runfile(‘C:/Users/xxx/Documents/bin/Anaconda/objet.py’, wdir=‘C:/Users/xxx/Documents/bin/Anaconda’)
0 1
1 3
2 5
3 0
4 6
5 8
dtype: int64

Result in Capella → NOK:

org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):
File “L/PyDevAccelerators/scripts/bo/test_edct.py”, line 8, in
# Contributors:
File “C:\APPSLEGACY\Anaconda3\lib\site-packages\pandas_init_.py”, line 17, in
“Unable to import required dependencies:\n” + “\n”.join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy: DLL load failed: Le module spécifié est introuvable.

Result in Capella:

import numpy

->NOK

org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):
File “L/PyDevAccelerators/scripts/bo/test_edct.py”, line 8, in
# Contributors:
File “C:\APPSLEGACY\Anaconda3\lib\site-packages\numpy_init_.py”, line 140, in
from . import _distributor_init
File “C:\APPSLEGACY\Anaconda3\lib\site-packages\numpy_distributor_init.py”, line 34, in
from . import _mklinit
ImportError: DLL load failed: Le module spécifié est introuvable.

I’m not a Python expert. I know we have an issue when numpy is installed in the Python interpreter. But it freezes execution… You can try to apply the same patch but I don’t think it will help.

From the message maybe this is an issue with the equivalent of classpath in Java. The path where _mklinit is located is not in the path Python4Capella/EASE looks ?

Thank you for your quick response, Yvan, unfortunately, I had already seen this link without finding the solution to my problem. I’m afraid I don’t understand the rest of your answer… Could you clarify your question for me?

I was thinking paths where the Python interpreter was looking for modules might not be the same in both cases. That could probably explain why in one case it couldn’t load the module _mklinit.

Can you run in both environment see if something is different:

import sys
print(sys.path)

I don’t see a significant difference:

spyder:

[‘C:\Users\xxx\Documents\bin\Anaconda’,
‘C:\APPSLEGACY\Anaconda3\python37.zip’,
‘C:\APPSLEGACY\Anaconda3\DLLs’,
‘C:\APPSLEGACY\Anaconda3\lib’,
‘C:\APPSLEGACY\Anaconda3’, ‘’,
‘C:\APPSLEGACY\Anaconda3\lib\site-packages’,
‘C:\APPSLEGACY\Anaconda3\lib\site-packages\win32’,
‘C:\APPSLEGACY\Anaconda3\lib\site-packages\win32\lib’,
‘C:\APPSLEGACY\Anaconda3\lib\site-packages\Pythonwin’,
‘C:\APPSLEGACY\Anaconda3\lib\site-packages\IPython\extensions’,
‘C:\Users\xxx\.ipython’]

Capella:

[‘C:\Program Files\capella1.4.2\eclipse\plugins\py4j-python_0.10.9.2-bnd-2odeag\src’,
‘C:\Program Files\capella1.4.2\eclipse\plugins\org.eclipse.ease.lang.python_0.7.0.I201906281229\pysrc’,
‘C:\Program Files\capella1.4.2\eclipse\plugins\org.eclipse.ease.lang.python.py4j_0.7.0.I201907020902\pysrc’,
‘C:\APPSLEGACY\Anaconda3\python37.zip’,
‘C:\APPSLEGACY\Anaconda3\DLLs’,
‘C:\APPSLEGACY\Anaconda3\lib’,
‘C:\APPSLEGACY\Anaconda3’,
‘C:\APPSLEGACY\Anaconda3\lib\site-packages’,
‘C:\APPSLEGACY\Anaconda3\lib\site-packages\win32’,
‘C:\APPSLEGACY\Anaconda3\lib\site-packages\win32\lib’,
‘C:\APPSLEGACY\Anaconda3\lib\site-packages\Pythonwin’]

We can try to see where the _mklinit module is loaded from in the spyder environment:

import _mklinit
print(_mklinit.__file__)

See is the location was listed in the sys.path of Python4Capella.

After a bit of searching it seems like it’s a DLL and can’t be loaded by the system (Windows). Not sure what is the best way to solve this.

At the system level you can add the following pathes to the system path, you probably want to double check this list:

C:\APPSLEGACY\Anaconda3
C:\APPSLEGACY\Anaconda3\Library\mingw-w64\bin
C:\APPSLEGACY\Anaconda3\Library\usr\bin
C:\APPSLEGACY\Anaconda3\Scripts

Maybe a less intrusive way using the Java java.library.path. In your capella.ini file next to the Capella executable, add this line after -vmargs (I’m not sure it will help since the interpreter is ran in an other process):

-Djava.library.path=C:\APPSLEGACY\Anaconda3:C:\APPSLEGACY\Anaconda3\Library\mingw-w64\bin:C:\APPSLEGACY\Anaconda3\Library\usr\bin:C:\APPSLEGACY\Anaconda3\Scripts

Let me know if it helps.

Spyder:

import _mklinit
print(_mklinit.__file__)

raises the following error :

ModuleNotFoundError: No module named '_mklinit'

Hello. I have no file named capella.ini.
however, a file named eclipse.ini exists and contains -vmargs. Unfortunately I don’t have the rights to modify it.

Yes in older versions of Capella it was eclipse.ini. I think you should ask someone from your IT to test those changes. Maybe they will have other idea as well.