PyInstaller is very convenient because you can convert a program written in Python into an executable file. Moreover, if you write it like the following, all the libraries will be combined into one file. Quite convenient.
How to convert test.py to test.exe:
$ pyinstaller test.py --onefile
You can install PyInstaller using pip as follows.
$ pip install pyinstaller
Support for macOS and newer Python versions has been delayed. Use the supported version.
If there is an implicit import, you will get an error. As shown below, add the implicit module by adding "--hidden-import = package name".
$ pyinstaller -F --hidden-import="sklearn.utils._cython_blas" --hidden-import="sklearn.neighbors.typedefs" --hidden-import="sklearn.neighbors.quad_tree" --hidden-import="sklearn.tree._utils" test.py
You can also include an implicit module as "import xxx" in your program.
Therefore, get the path of the exe file with sys.argv [0].
test.py
import os, sys
exe = os.path.abspath(sys.argv[0])
exe_dir = os.path.dirname(exe)
-When an error occurs --stackoverflow -(Notes when converting to EXE) https://qiita.com/ymdymd/items/f9f5587f0f3128285e25
Recommended Posts