1

Try to create exe file from python scipt with imported module scipy.signals. Pyinstaller perform well with no errors but new .exe file gives me error like :

Failed to decode wchar_t from UTF-8
MultiByteToWideChar: ╬сырёЄ№ фрээ√ї, яхЁхфрээр  яю ёшёЄхьэюьє т√чютє, ёыш°ъюь ьрыр.
share\jupyter\lab\staging\node_modules\.cache\terser-webpack-plugin\content-v2\sha512\2e\ba\cfce62ec1f408830c0335f2b46219d58ee5b068473e7328690e542d2f92f2058865c600d845a2e404e282645529eb0322aa4429a84e189eb6b58c1b97c1a could not be extracted!

BUT when I change row in a py file from

from scipy imports signals

to

import scipy

exec file perform great. Any suggestions?

1 Answers1

0

I had a similar issue when packaging up an script that used xarray. The solution was to find out which package was importing jupyter, and add it to the list of excluded-modules. In my case, I excluded dask, but in your case things will be different.

I would rerun your pyinstaller command with --log-level DEBUG in order to get some more logging information, then take a look at the log files generated in the build/ directory. If you have graphviz, or know how to work with graphs, then you can analyze the .dot file to learn about the packages that install jupyter/IPython. If you don't know how to use graphviz, no problem, just open up the html file in a browser. This file shows all of the packages imported by your script, and all of the packages that those packages import, and are imported by, etc. Beware, this is a really complex web of package A imports ... and package A is imported by ..., so don't get lost in the details.

The goal here is to find the path of imports that leads from your script to IPython/jupyter that is leading to this issue. You want to stop this path wherever seems logical for your script. In your case, many of the scipy subpackages import matplotlib.pyplot, which imports IPython, which imports things which eventually import jupyter_client. You want to sever this path from your script to jupyter/IPython as early as you can by excluding one of the packages. The package you decide to exclude will depend on your app.

The easiest way to get rid of this error would be to sever this path from your script to jupyter by excluding matplotlib. However, if you use matplotlib in your script to generate plots, then you can't do that. You would have to pick a package that is more downstream. Ultimately you could exclude IPython, and that should do the trick. Take a look at the pyinstaller documentation for how to use the --exclude-module argument:

https://pyinstaller.readthedocs.io/en/stable/usage.html#what-to-bundle-where-to-search

Or this stackoverflow question which has some more info:

How to remove/exclude modules and files from pyInstaller?

On a side note, you should start getting comfortable excluding unnecessary packages since this can drastically decrease the size of your bundled app and improve performance.

Nico Bako
  • 99
  • 1
  • 4