Installing Pyinstaller
For those who have a stable network and can use the PIP source address smoothly, the following command can be done directly:
Pip Install Pyinstaller
Usually we will download the source package, then go to the package directory, execute the following command (need to install Setuptools):
Python setup.py Install
For additional installation options, see the Manual and Pip User Guide.
To install the current development version, use:
Pip Install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz
After installation, check that the installation is successful or not:
pyinstaller --version
Once the installation is successful, you can use the following command:
pyinstaller
: The main command for packaging executables, detailed usage is described below.
pyi-archive_viewer
: View the list of files in the executable package.
pyi-bindepend
: View the dynamic library (. So or. dll file) on which the executable file is dependent
pyi-...
And so on
When executing a pyInstaller
command, a file is generated in the same directory as the script, which .spec
tells Pyinstaller how to process all of your scripts and includes command options. Generally we don't have to bother with this file, if you need to package a data file, or add some Python run-time options to the packaged binary ... Some advanced packaging options require you to manually edit the .spec
files. You can use:
pyi-makespec options script [script ...]
Using Pyinstaller
pyinstaller
The syntax:
pyinstaller [options] script [script ...] | specfile
The simplest usage is to execute the command in the same directory as the myscript.py:
pyinstaller mycript.py
You will then see a new addition of two directory build and dist,dist the following files are executable files that can be published, for the above command you will find a bunch of files under the Dist directory, various dynamic library files and Myscrip executables. Sometimes this feeling is more troublesome, need to pack dist all the things below to publish, in case you lose a dynamic library can not run, fortunately Pyinstaller support single file mode, only need to execute:
pyinstaller -F mycript.py
You will find that there is only one executable file under Dist, this single file can be published and run under a system similar to the operating system you are using.
Error:
If Python is not the default installation path, the corresponding library file may not be found:
Traceback (most recent): File"/xs/app/python3.5/bin/pyinstaller", line One,inch<module>Sys.exit (Run ()) File"/xs/app/python3.5/lib/python3.5/site-packages/pyinstaller/__main__.py", line94,inchRun Run_build (pyi_config, Spec_file,**VARs (args)) File"/xs/app/python3.5/lib/python3.5/site-packages/pyinstaller/__main__.py", line $,inchrun_build PyInstaller.building.build_main.main (Pyi_config, Spec_file,**Kwargs) File"/xs/app/python3.5/lib/python3.5/site-packages/pyinstaller/building/build_main.py", line791,inchMain Build (specfile, KW.Get('Distpath'), KW.Get('Workpath'), KW.Get('Clean_build')) File"/xs/app/python3.5/lib/python3.5/site-packages/pyinstaller/building/build_main.py", line737,inchbuild exec (text, spec_namespace) File"<string>", line -,inch<module>File"/xs/app/python3.5/lib/python3.5/site-packages/pyinstaller/building/build_main.py", line213,inch__init__ self.__postinit__ () File"/xs/app/python3.5/lib/python3.5/site-packages/pyinstaller/building/datastruct.py", line161,inch__postinit__ self.assemble () File"/xs/app/python3.5/lib/python3.5/site-packages/pyinstaller/building/build_main.py", line545,inchAssemble Self._check_python_library (self.binaries) File"/xs/app/python3.5/lib/python3.5/site-packages/pyinstaller/building/build_main.py", line629,inch_check_python_library raise IOError (msg) Oserror:python Library not found:libpython3.5mu.so.1.0, Libpython3.5. So.1.0, libpython3.5m.so.1.0This would mean your Python installation doesn't come with proper library files.This usually happens by missing development package, or unsuitable build parameters of Python installation.* on debian/Ubuntu, you would need to install Python development packages* apt-GetInstall python3-Dev* apt-GetInstall python-Dev* If You're building python by yourself, please rebuild your python with '--enable-shared ' (or, '--enable-framework ' on Darwin)
Workaround:
1. Compile/etc/ld.so.conf, add:/usr/local/lib64/usr/local/lib2. Ldconfig3. Re-pyinstaller the file
Package a Python script as an executable file