使用pyinstaller 对py脚本进行打包(生成linux可执行文件)

需求1:打包成Linux上可执行程序
a. 先下载pyinstaller程序,我当前下载的是PyInstaller-2.1的版本
进行如下操作:

pythoner@pythoner-virtual-machine:~/PyInstaller-2.1$ sudo python2.7 setup.py install
pythoner@pythoner-virtual-machine:~/PyInstaller-2.1$ pwd
/home/pythoner/PyInstaller-2.1

#生成一个单文件可执行的spec文件

pythoner@pythoner-virtual-machine:~/PyInstaller-2.1$ ./utils/makespec.py --onefile ~/05.py 
wrote /home/pythoner/PyInstaller-2.1/05/05.spec
now run pyinstaller.py to build the executable

#将该spec文件进行构建,生成一个独立的可执行文件
#这个文件在 /home/pythoner/PyInstaller-2.1/utils下面

pythoner@pythoner-virtual-machine:~/PyInstaller-2.1$ ./utils/build.py 05/05.spec 
42 INFO: UPX is not available.
83 INFO: Processing hook hook-os
248 INFO: Processing hook hook-time
251 INFO: Processing hook hook-cPickle
347 INFO: Processing hook hook-_sre
475 INFO: Processing hook hook-cStringIO
589 INFO: Processing hook hook-encodings
606 INFO: Processing hook hook-codecs
1086 INFO: Extending PYTHONPATH with /home/pythoner
1086 INFO: checking Analysis
1101 INFO: checking PYZ
1109 INFO: checking PKG
1110 INFO: checking EXE
#文件生成了!
pythoner@pythoner-virtual-machine:~/PyInstaller-2.1$ stat 05/dist/05
  File: ‘05/dist/05’
  Size: 4230711       Blocks: 8264       IO Block: 4096   regular file
Device: 801h/2049d    Inode: 4196956     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/pythoner)   Gid: ( 1000/pythoner)
Access: 2014-04-28 21:45:40.110497178 +0700
Modify: 2014-04-28 21:45:20.806496857 +0700
Change: 2014-04-28 21:45:20.806496857 +0700
Birth: -

转载于:https://www.cnblogs.com/start0cheng/p/3699234.html

你可能感兴趣的:(使用pyinstaller 对py脚本进行打包(生成linux可执行文件))