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

can't build with matplotlib #5075

Closed
aglavic opened this issue Aug 10, 2020 · 6 comments
Closed

can't build with matplotlib #5075

aglavic opened this issue Aug 10, 2020 · 6 comments
Assignees

Comments

@aglavic
Copy link

aglavic commented Aug 10, 2020

I'm trying to get a program with embedded matplotlib graphs to build as .exe on windows 10 and no matter what I try the final program always crashes without error when run independently. I am building using an anaconda environment and when I start the .exe from that environment it does not crash.

I find the same behavior for the embedded examples of wxagg and qtagg, but this is the minimal example that does not work:

import matplotlib.pyplot as plt

plt.plot([0,1,2], [0,1,1])
plt.show()

I have attached the example and the .yml file to create the anaconda environment from scratch here:
pyinstaller_issue_matplotlib.zip

I have tried with python 3.6 and 3.7, matplotlib 3.0.x, 3.1.x, 3.2.x and pyinstaller 3.4,3.5,3.6,4.0,4.1-dev and none seem to work.
Using the --debug all options I see it crashing after import of matplotlib.pylab (or matplotlib.backend_wxagg in the embedded example).

I got this working half a year ago, but I don't know what changed with the environment. Any help to track down the issue would be appreciated. (Or an environment definition that works.)

@bwoodsend
Copy link
Member

@aglavic Can we have the runtime traceback? I'm aware that Conda numpy is broken and matplotlib>=3.3 is also causing issues with its data. It could be either of those or something new...

@aglavic
Copy link
Author

aglavic commented Aug 12, 2020

Hi @bwoodsend, thanks for the quick reply. I'm not sure if you were referring to the traceback when building with pyinstaller or the execution of the package, so here are both logs:

build.log
run.log

There is a warning about dependencies of the mkl libraries that numpy uses, but I can't finde these dlls anywhere on my system and another package that uses numpy worked.

@bwoodsend
Copy link
Member

I meant the runtime log (your run.log).

I can't finde these dlls anywhere on my system

Use the following to find conda dll locations:

conda activate
where dll_name.dll

Those particular dlls aren't present on my machine either so they hopefully are not needed.

another package that uses numpy worked
I'm afraid that doesn't prove anything - to see the crash you need to invoke specific functions in numpy.

@bwoodsend
Copy link
Member

The error in your error log has no proper Python stacktrace which is Conda's way of saying missing dll. I can't reproduce I'm afraid. It works fine for me but this is typical Conda - it could be accessing a dll anywhere on my machine (typically these dlls are also in other programs I have installed), giving me the illusion that the app works when it doesn't.

We don't want to support Conda for exactly this (among many other) reasons. A missing dll should both be rare and easy to diagnose but with Conda it's neither. Please do us all a favour and use a normal Python with PyInstaller. You can have multiple installed alongside Conda without them getting in each other's way.

If you're determined to use Conda then your next step would be to trace Python executing your script. In English this means appending something like the following to your code:

import psutil
python = psutil.Process()
print(python.memory_maps())

Then compare the output filenames with what is being included in your app by PyInstaller. Doing this is incredibly tedious and time-consuming so the PyInstaller devs won't do this - you'll have to do it yourself and fix the hooks if you want this supported.

@aglavic
Copy link
Author

aglavic commented Aug 12, 2020

Thank you so much for the tip with memory_maps. I could easily track down the issue by simply dumping the map before and after the command that crashed and diffing the result.

For me it was just a missing libiomp5md.dll which I could copy to the exe path to solve this.

@bwoodsend
Copy link
Member

Actually I probably should have told you at the start. libiomp5md.dll is the rouge numpy dll that causes any numpy linear algebra to crash.

bwoodsend added a commit to bwoodsend/pyinstaller that referenced this issue Sep 14, 2020
Whilst I'm here also:

- Exclude numpy's testing and C/Fortran compiling code, and
  everything else it drags with it (namely scipy).
- Try to fix Conda support.
- Avoid dragging 400MB of unused MKL DLLs on Conda.

They're all closed due to our no-conda policy but, (for now) fixes
 pyinstaller#4935, pyinstaller#4968, pyinstaller#5075, pyinstaller#5082, pyinstaller#5019 and pyinstaller#5019. Although likely at
the expense of junk DLLs being dragged in.
bwoodsend added a commit to bwoodsend/pyinstaller that referenced this issue Sep 17, 2020
Whilst I'm here also:

- Exclude numpy's testing and C/Fortran compiling code, and
  everything else it drags with it (namely scipy).
- Try to fix Conda support.
- Avoid dragging 400MB of unused MKL DLLs on Conda.

They're all closed due to our no-conda policy but, (for now) fixes
 pyinstaller#4935, pyinstaller#4968, pyinstaller#5075, pyinstaller#5082, pyinstaller#5019 and pyinstaller#5019. Although likely at
the expense of junk DLLs being dragged in.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants