python打包linux可执行文件

方法

前段时间尝试使用Python的tkinter制作了一个简单的丑丑的图形化界面,现在想把它打包成Linux可执行文件,具体步骤如下:

1.安装环境

使用的工具是pyinstaller,打开终端输入 sudo pip install pyinstaller

sudo pip install pyinstaller

2.打包程序

首先在打包之前检查一下我们的py文件是否可以正常执行,确认无误后进行打包 pyinstaller -F car_tkinter.py

pyinstaller -F car_tkinter.py

dyj@DYJ: ~/CarUI$ pyinstaller -F car_tkinter .py.25INFO: PyInstaliler: 4.3
25INFO:Python : 3.6.9
25 INFO: Platforn: Linux-5.4.0-73-generic-x86_64-with-Ubuntu-18.04-bionic26 INFO: wrote /hone/dyj/CarUI/car_tkinter.spec
27 INFO:UPX is not available.
29 INFO:Extending PYTHONPATH with paths[ '/home/dyj/CarUI'. ' /home/dyj/carUI'132INFO:checking Analysis
40 INFO: checking PYz
41 INFO: checking PKG
43 INFO: Bootloader /usr/local/lib/python3.6/dist-packages/PyInstaller /bootloader /Linux-64bit/run
43INFO: checking EXE
45 INFO: Rebuilding EXE-00.toc because car_tkinter missing45 INFO:Building EXE from EXE-00.toc
45 INFO: Appending archive to ELF section in EXE /hone/dyj/CarUI/dist/car_tkinter
71 INFO:Building EXE fron EXE-00.toc completed successfullv,

打包成功。

3.执行文件

进入我们打包存放的文件夹(在上图倒数第二句处查看),打开终端,执行语句./car_tkinter

1l ./car_tkinter
成功执行!

  •