Linux下安装Pyinstaller并进行打包

一、Pyinstaller安装

$pip3 install pyinstaller

二、Pyinstaller打包

  • 命令格式:$pyinstaller -F runclient_main.py

打包后新增文件如下。

在当前目录中会出现一个dist目录。生成的可执行文件在这个目录下。

三、执行可执行文件

$./runclient_main

 

例子2:

$pyinstaller -F casb_init.py

[root@localhost python_deploy]# pyinstaller -F casb_init.py
137 INFO: PyInstaller: 4.2
137 INFO: Python: 3.6.8
159 INFO: Platform: Linux-4.4.206-1.el7.elrepo.x86_64-x86_64-with-centos-7.2.1511-Core
160 INFO: wrote /home/cg/python_deploy/casb_init.spec
166 INFO: UPX is not available.
170 INFO: Extending PYTHONPATH with paths
['/home/cg/python_deploy', '/home/cg/python_deploy']
187 INFO: checking Analysis
188 INFO: Building Analysis because Analysis-00.toc is non existent
188 INFO: Initializing module dependency graph...
191 INFO: Caching module graph hooks...
208 WARNING: Several hooks defined for module 'win32ctypes.core'. Please take care they do not conflict.
220 INFO: Analyzing base_library.zip ...
10999 INFO: Caching module dependency graph...
11313 INFO: running Analysis Analysis-00.toc
11361 INFO: Analyzing /home/cg/python_deploy/casb_init.py
11703 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from '/usr/local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-urllib3.packages.six.moves.py'.
18460 INFO: Processing module hooks...
18460 INFO: Loading module hook 'hook-certifi.py' from '/usr/local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'...
18481 INFO: Loading module hook 'hook-difflib.py' from '/usr/local/lib/python3.6/site-packages/PyInstaller/hooks'...
18484 INFO: Excluding import of doctest from module difflib
18484 INFO: Loading module hook 'hook-encodings.py' from '/usr/local/lib/python3.6/site-packages/PyInstaller/hooks'...
18750 INFO: Loading module hook 'hook-heapq.py' from '/usr/local/lib/python3.6/site-packages/PyInstaller/hooks'...
18755 INFO: Excluding import of doctest from module heapq
18756 INFO: Loading module hook 'hook-pickle.py' from '/usr/local/lib/python3.6/site-packages/PyInstaller/hooks'...
18759 INFO: Excluding import of argparse from module pickle
18759 INFO: Loading module hook 'hook-xml.py' from '/usr/local/lib/python3.6/site-packages/PyInstaller/hooks'...
18974 INFO: Looking for ctypes DLLs
18974 INFO: Analyzing run-time hooks ...
18986 INFO: Including run-time hook '/usr/local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/rthooks/pyi_rth_certifi.py'
19019 INFO: Looking for dynamic libraries
19993 INFO: Looking for eggs
19994 INFO: Using Python library /lib64/libpython3.6m.so.1.0
20012 INFO: Warnings written to /home/cg/python_deploy/build/casb_init/warn-casb_init.txt
20166 INFO: Graph cross-reference written to /home/cg/python_deploy/build/casb_init/xref-casb_init.html
20198 INFO: checking PYZ
20199 INFO: Building PYZ because PYZ-00.toc is non existent
20199 INFO: Building PYZ (ZlibArchive) /home/cg/python_deploy/build/casb_init/PYZ-00.pyz
21449 INFO: Building PYZ (ZlibArchive) /home/cg/python_deploy/build/casb_init/PYZ-00.pyz completed successfully.
21470 INFO: checking PKG
21471 INFO: Building PKG because PKG-00.toc is non existent
21471 INFO: Building PKG (CArchive) PKG-00.pkg
26076 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
26085 INFO: Bootloader /usr/local/lib/python3.6/site-packages/PyInstaller/bootloader/Linux-64bit/run
26085 INFO: checking EXE
26086 INFO: Building EXE because EXE-00.toc is non existent
26086 INFO: Building EXE from EXE-00.toc
26089 INFO: Appending archive to ELF section in EXE /home/cg/python_deploy/dist/casb_init
27024 INFO: Building EXE from EXE-00.toc completed successfully.

 

 

 

 

 

 

 

 

 

 

 

Logo

更多推荐