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

Matplotlib window doesn't open #5605

Closed
JogeHB opened this issue Mar 5, 2021 · 2 comments
Closed

Matplotlib window doesn't open #5605

JogeHB opened this issue Mar 5, 2021 · 2 comments

Comments

@JogeHB
Copy link

JogeHB commented Mar 5, 2021

Hey there,
I'm struggling with pyinstaller and matplotlib. I'm able to get a .exe from my python code but when I include something with matplotlib the console of the exe doesn't open the matplotlib window and ends the run.

I simplified it to:

import matplotlib.pyplot as plt

x = [0,1,2,3]
y = x

plt.plot(x,y)

plt.show()

I run pyinstaller with:

pyinstaller --debug=all --hidden-import matplotlib.backends --distpath path2dist --workpath path2work simple_plot.py

Running the resulting .exe works on the same computer/user (the matplotlib window opens). However, when I change the user for testing the compatibility of the .exe, the console runs trough the program without opening the matplotlib window. The last lines of the console are:

import 'matplotlib.backends.qt_editor._formsubplottool' # <_frozen_importlib_external.SourcelessFileLoader object at 0x0000027ED17817F0>
import 'matplotlib.backends.backend_qt5' # <_frozen_importlib_external.SourcelessFileLoader object at 0x0000027ED1768AF0>
import 'matplotlib.backends.backend_qt5agg' # <_frozen_importlib_external.SourcelessFileLoader object at 0x0000027ED174DBB0>
import 'matplotlib.pyplot' # <_frozen_importlib_external.SourcelessFileLoader object at 0x0000027ECF8ED7C0>
# PyQt5.QtX11Extras not found in PYZ

So, no direct Error message.
I'm working on Windows, Python 3.8.5, PyInstaller 4.2, Matplotlib 3.3.2.

My normal, non-reduced python code defines a gui in which you can press a button and a matplotlib plot should appear. There, when pressing the button, no matplotlib window occurs and the gui closes. Before doing so, everything works fine for the other parts of the gui. After the gui has closed you can find the same last lines within the console as shown above.

What I already checked:

  • Pyinstaller hooks (nltk, matplotlib, matplotlib.backends). Matplotlib related updates of them suggested in earlier questions are already implemented in PyInstaller 4.2.
  • PyInstaller messages related to matplotlib during .exe generation:
171020 INFO:   Matplotlib backend "GTK3Agg": ignored
    The GTK3 backends require PyGObject
171506 INFO:   Matplotlib backend "GTK3Cairo": ignored
    The GTK3 backends require PyGObject
171822 INFO:   Matplotlib backend "MacOSX": ignored
    cannot import name '_macosx' from 'matplotlib.backends' (c:\users\jonah\anaconda3\lib\site-packages\matplotlib\backends\__init__.py)
172656 INFO:   Matplotlib backend "nbAgg": added
<string>:12: MatplotlibDeprecationWarning:
The matplotlib.backends.backend_qt4agg backend was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
173141 INFO:   Matplotlib backend "Qt4Agg": added
<string>:12: MatplotlibDeprecationWarning:
The matplotlib.backends.backend_qt4cairo backend was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
173589 INFO:   Matplotlib backend "Qt4Cairo": added
174113 INFO:   Matplotlib backend "Qt5Agg": added
174576 INFO:   Matplotlib backend "Qt5Cairo": added
175062 INFO:   Matplotlib backend "TkAgg": added
175863 INFO:   Matplotlib backend "TkCairo": added
176364 INFO:   Matplotlib backend "WebAgg": added
176850 INFO:   Matplotlib backend "WX": ignored
    No module named 'wx'
177198 INFO:   Matplotlib backend "WXAgg": ignored
    No module named 'wx'
177520 INFO:   Matplotlib backend "WXCairo": ignored
    No module named 'wx'
177899 INFO:   Matplotlib backend "agg": added
178307 INFO:   Matplotlib backend "cairo": added
178824 INFO:   Matplotlib backend "pdf": added
179325 INFO:   Matplotlib backend "pgf": added
179704 INFO:   Matplotlib backend "ps": added
180089 INFO:   Matplotlib backend "svg": added
180628 INFO:   Matplotlib backend "template": added
181330 INFO: Loading module hook 'hook-matplotlib.py' from 'c:\\users\\jonah\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
  • Reverting to older versions of matplotlib didn't work & causes other problems due to other dependecies within the rest of the code.

Looking forward to some new ideas to solve the issue.
Thanks in advance!
Jonah

@rokm
Copy link
Member

rokm commented Mar 5, 2021

Since you're using anaconda, the silent crash of frozen application is probably caused by numpy missing the libiomp5md DLL.

Try using develop version of PyInstaller (which has #5168 merged). Or, try to bundle that missing DLL using work-around from #4968 (comment).

@JogeHB
Copy link
Author

JogeHB commented Mar 6, 2021

Since you're using anaconda, the silent crash of frozen application is probably caused by numpy missing the libiomp5md DLL.

Try using develop version of PyInstaller (which has #5168 merged). Or, try to bundle that missing DLL using work-around from #4968 (comment).

Nice! The change of hook-numpy.py as described in #5168 makes it work.

Thanks a lot!

@rokm rokm closed this as completed Mar 6, 2021
@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.
Projects
None yet
Development

No branches or pull requests

2 participants