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

PyInstaller executable with matplotlib cannot find _cext DLL #168

Open
mapcreatorGuus opened this issue Sep 13, 2023 · 6 comments
Open

PyInstaller executable with matplotlib cannot find _cext DLL #168

mapcreatorGuus opened this issue Sep 13, 2023 · 6 comments

Comments

@mapcreatorGuus
Copy link

I used PyInstaller 5.13.2 to create an executable that uses Matplotlib 3.7.3 (and therefore also Kiwisolver 1.4.5).
This creates an executable that runs fine on my developer computer, but crashes on the _cext DLL import on another machine:

image

I'm not sure what other information I can provide that could be useful here. Let me know if you need to know anything else.

@MatthieuDartiailh
Copy link
Member

I have no personal experience with PyInstaller but is it possible it somehow forgot to package the compiled dll for kiwi ? That's how I read error message.
You should have both a _cext.pyi and a .pyd in your install, PyInstaller may have packaged only the .pyi.

@mapcreatorGuus
Copy link
Author

As far as my expertise goes in this regard, it seems to be the other way around: only the pyd (_cext.cp311-win_amd64.pyd) is present.

I'm not entirely sure what to try next and if this is even the problem of kiwisolver or perhaps of PyInstaller instead. This paragraph on the pyinstaller wiki may be related: https://pyinstaller.org/en/v5.13.2/when-things-go-wrong.html#listing-hidden-imports. It seems that, generally, pyinstaller leaves it up to other packages to contribute their own hooks so that packages can be frozen properly, but this could also be an issue on their end.

@MatthieuDartiailh
Copy link
Member

Kiwi has no hidden imports. Could you post the content of the kiwi package in the install created by PyInstaller ?

@mapcreatorGuus
Copy link
Author

Just to clarify: I cannot completely view the results of builds as I run PyInstaller with --onefile, which creates a single self-contained exectuable. My findings about the package contents regard those when I use PyInstaller without the --onefile option.

That being said, the installed package contains a kiwisolver folder with inside it only the file "_cext.cp311-win_amd64.pyd".

Another perhaps useful thing me and a colleague discovered in the meantime is the following: when I place msvcp140.dll next to my executable, it does run fine. This suggests that that dll is not properly included when freezing my project with PyInstaller.

@MatthieuDartiailh
Copy link
Member

This is weird on several level:

  • to run you need the exceptions.py file from which some things are imported by _cext
  • you also need __init__.py since typically users are not expected to use functionalities beyond this
  • when building the installer you can set the env var KIWI_DISABLE_FH4 to avoid linking against VCRUNTIME140_1.dll (I mention it since you have a windows dll issue even though it does not seem related to this exact dll).

@mapcreatorGuus
Copy link
Author

I'm not really sure how to proceed with this. My personal runtime problem is solved by manually including the msvcp140.dll in the PyInstaller build, but I do not think that is a satisfying solution for this situation.

The way I see it now the desired solution would be either of the following:

But maybe I'm overlooking something, let me know what you think.
Anyway, I really appreciate your help so far :)

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

No branches or pull requests

2 participants