使用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: -


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM