ylikx / forpy

Forpy - use Python from Fortran

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`UserWarning: mkl-service package failed to import ` in the import example

Lancashire3000 opened this issue · comments

Hi,

I tried to do the example about import in https://github.com/ylikx/forpy#import-a-python-module-in-fortran

By gfortran -c forpy_mod.F90
and gfortran py-import.f90 forpy_mod.o python3-config --ldflags --embed -fno-lto -static-libgfortran (I named the file as py-import.f90 )

then run a.out, I got

/home/user/intel/oneapi/intelpython/latest/envs/idp-2/lib/python3.8/site-packages/numpy/__init__.py:159: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
  from . import _distributor_init

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7fd9f1b886aa
#1  0x7fd9f1b87fb5
#2  0x7fd9f14f620f
#3  0x7fd9f1a4e17e
#4  0x7fd9f1afd2a4
#5  0x7fd9f1ae1f08
#6  0x7fd9f1ae2137
#7  0x7fd9f14d70b2
#8  0x7fd9f1ae1ddd
#9  0xffffffffffffffff
Segmentation fault (core dumped)

My python 3.8.11 is from https://software.intel.com/en-us/python-distribution and https://www.intel.com/content/www/us/en/developer/articles/technical/using-intel-distribution-for-python-with-anaconda.html, not sure if intel-python has any issue with forpy

If I create a new conda environment with python=3.8, conda install -c conda-forge fypp, then
gfortran -c forpy_mod.F90
gfortran py-import.f90 forpy_mod.o python3-config --ldflags --embed -fno-lto
./a.out

I got

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7f6437c31700 in ???
#1  0x7f6437c308a5 in ???
#2  0x7f643790620f in ???
#3  0x7f64380a544e in PyObject_GetAttr
#4  0x7f6438153ed4 in __forpy_mod_MOD_object_getattribute
#5  0x7f6438138b38 in MAIN__
#6  0x7f6438138d67 in main
Segmentation fault (core dumped)

Anaconda changed how its cpython is built. This should help: #25

Thank you so much! gfortran py-import.f90 forpy_mod.o python3-config --ldflags --embed -fno-lto -static-libgfortran -Xlinker -export-dynamic
leads to Today is 2022-01-13
It works!