Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pylibkriging import fails on Windows #103

Closed
hpwxf opened this issue May 31, 2021 · 7 comments · Fixed by #117
Closed

pylibkriging import fails on Windows #103

hpwxf opened this issue May 31, 2021 · 7 comments · Fixed by #117

Comments

@hpwxf
Copy link
Member

hpwxf commented May 31, 2021

on: Python 3.9.5

$ pip install pylibkriging
Collecting pylibkriging
  Downloading pylibkriging-0.4.1-cp39-cp39-win_amd64.whl (252 kB)
     |████████████████████████████████| 252 kB ...
Installing collected packages: pylibkriging
Successfully installed pylibkriging-0.4.1

But

ImportError: DLL load failed while importing pylibkriging: The specified module could not be found.
@yannrichet
Copy link
Member

Is numpy version OK ? >=1.20

@hpwxf
Copy link
Member Author

hpwxf commented Jun 1, 2021

Python 3.7 + Windows : OK
But
Python 3.8 or 3.9 + Windows : fails (same DLL load error).

  • openblas.dll is not embedded in python DLL

@hpwxf
Copy link
Member Author

hpwxf commented Jun 1, 2021

NB: when it fails because sub-DLL is missing, the error is ImportError: DLL load failed: The specified module could not be found.

Moreover, using Dependencies, we can see minor differences between .pyd (dll) file from releases 3.6 (<), 3.7 (#) and 3.8 (>).

  • apisets : Same
  • apisetsdll : Same
  • chain :
< □ pylibkriging.cp36-win_amd64.pyd (ROOT) : G:/python-artifact/pylibkriging-0.4.1-cp36-cp36m-win_amd64/pylibkriging.cp36-win_amd64.pyd
< |  □ python36.dll (Environment) : C:\Python36\python36.dll
---
# □ pylibkriging.cp37-win_amd64.pyd (ROOT) : G:/python-artifact/pylibkriging-0.4.1-cp37-cp37m-win_amd64/pylibkriging.cp37-win_amd64.pyd
# |  □ python37.dll (Environment) : C:\Python37\python37.dll
---
> □ pylibkriging.cp38-win_amd64.pyd (ROOT) : G:/python-artifact/pylibkriging-0.4.1-cp38-cp38-win_amd64/pylibkriging.cp38-win_amd64.pyd
> |  □ python38.dll (Environment) : C:\Python38\python38.dll
  • exports :
< Export 1 :
<         Name : PyInit_pylibkriging
<         VA : 0xE550
---
# Export 1 :
#         Name : PyInit_pylibkriging
#         VA : 0xE570
---
> Export 1 :
>         Name : PyInit_pylibkriging
>         VA : 0xE210
  • imports :
< Import from module python36.dll:
# Import from module python37.dll:
many Function PyThread_* between 3.6 and 3.7 (not 3.7 and 3.8 except the following)
> Import from module python38.dll :
>        Function _Py_Dealloc
  • knowndll : Same
  • manifest : Same (except DLL name)
  • modules :
< [ROOT] pylibkriging.cp36-win_amd64.pyd : G:/python-artifact/pylibkriging-0.4.1-cp36-cp36m-win_amd64/pylibkriging.cp36-win_amd64.pyd
# [ROOT] pylibkriging.cp37-win_amd64.pyd : G:/python-artifact/pylibkriging-0.4.1-cp37-cp37m-win_amd64/pylibkriging.cp37-win_amd64.pyd
> [ROOT] pylibkriging.cp38-win_amd64.pyd : G:/python-artifact/pylibkriging-0.4.1-cp38-cp38-win_amd64/pylibkriging.cp38-win_amd64.pyd
< [Environment] python36.dll : C:\Python36\python36.dll
# [Environment] python37.dll : C:\Python37\python37.dll
> [Environment] python38.dll : C:\Python38\python38.dll
  • sxsentries :
< [-] sxs dependencies for executable : G:/python-artifact/pylibkriging-0.4.1-cp36-cp36m-win_amd64/pylibkriging.cp36-win_amd64.pyd
---
# [-] sxs dependencies for executable : G:/python-artifact/pylibkriging-0.4.1-cp37-cp37m-win_amd64/pylibkriging.cp37-win_amd64.pyd
---
> [-] sxs dependencies for executable : G:/python-artifact/pylibkriging-0.4.1-cp38-cp38-win_amd64/pylibkriging.cp38-win_amd64.pyd

@hpwxf
Copy link
Member Author

hpwxf commented Jun 1, 2021

See also #86.

@hpwxf
Copy link
Member Author

hpwxf commented Jun 1, 2021

Is numpy version OK ? >=1.20

Yes, for all configurations:

 pip show numpy
Name: numpy
Version: 1.20.3

@hpwxf
Copy link
Member Author

hpwxf commented Jun 1, 2021

@hpwxf
Copy link
Member Author

hpwxf commented Aug 27, 2021

(cf https://stackoverflow.com/a/62891703/12430075)

It could be that your C++ python library itself depends on a shared library / DLL. Python 3.7/3.6 would search for DLLs in PATH or the current working directory, but this is no longer the case in Python 3.8:

https://docs.python.org/3.8/whatsnew/3.8.html#ctypes

If this is the problem, you can add use add_dll_directory() to tell Python 3.8 where it should look for the DLLs.

hpwxf added a commit to haveneer/libKriging that referenced this issue Aug 27, 2021
Python ≥3.8 on Windows does not load DLL from path but using os.add_dll_directory()
@hpwxf hpwxf linked a pull request Sep 4, 2021 that will close this issue
@hpwxf hpwxf closed this as completed in #117 Sep 4, 2021
hpwxf added a commit that referenced this issue Sep 4, 2021
* Fix python binding. It solves issues: #109, #103 and #86.
* Pybind11, carma and armadillo dependencies have updated or upgraded.
* Build chain has also been upgraded to follow evolutions of theses libs.
* A dedicated memory allocator is now defined in libKriging to drive memory management in armadillo, mostly when linked to Python.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants