日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python如何編譯成exe

python 程序都是腳本的方式,一般是在解析器里運行,如果要發(fā)布出去,需要提前安裝解析器才可以運行,為了在 Windows 里方便發(fā)布,只要點擊一個 EXE 文件運行,并且打包所需要庫文件,這樣發(fā)布給用戶使用就會更方便。

10年積累的網(wǎng)站制作、成都網(wǎng)站建設(shè)經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認識你,你也不認識我。但先建設(shè)網(wǎng)站后付款的網(wǎng)站建設(shè)流程,更有嘉定免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

PyInstaller

PyInstaller 是一個十分有用的第三方庫,可以用來打包 python 應(yīng)用程序,打包完的程序就可以在沒有安裝 Python 解釋器的機器上運行了。

更多相關(guān)知識,可以參考這篇文章:《python如何編譯成exe文件》

它能夠在 Windows、Linux、 Mac OS X 等操作系統(tǒng)下將 Python 源文件打包,通過對源文件打包, Python 程序可以在沒有安裝 Python 的環(huán)境中運行,也可以作為一個 獨立文件方便傳遞和管理。

PyInstaller 支持 Python 2.7 / 3.4-3.7??梢栽?Windows、Mac OS X 和 Linux 上使用,但是并不是跨平臺的,而是說你要是希望打包成 .exe 文件,需要在 Windows 系統(tǒng)上運行 PyInstaller 進行打包工作。

下面我們以 Windows 為例來進行程序的打包工作。

安裝

pip install pyinstaller
# 或者
python -m pip install pyinstaller

使用

pyinstaller -F helloworld.py

其中,-F 表示打包成單獨的 .exe 文件,這時生成的 .exe 文件會比較大,而且運行速度回較慢。僅僅一個 helloworld 程序,生成的文件就 5MB 大。

另外,使用 -i 還可以指定可執(zhí)行文件的圖標(biāo);

-w 表示去掉控制臺窗口,這在 GUI 界面時非常有用。不過如果是命令行程序的話那就把這個選項刪除吧!

PyInstaller 會對腳本進行解析,并做出如下動作:

1、在腳本目錄生成 helloworld.spec 文件;

2、創(chuàng)建一個 build 目錄;

3、寫入一些日志文件和中間流程文件到 build 目錄;

4、創(chuàng)建 dist 目錄;

5、生成可執(zhí)行文件到 dist 目錄;

執(zhí)行流程:

$ pyinstaller -F helloworld.py
838 INFO: PyInstaller: 3.4
839 INFO: Python: 3.4.3
841 INFO: Platform: Windows-8-6.2.9200
842 INFO: wrote d:\code\Python\pyinstaller\helloworld.spec
858 INFO: UPX is not available.
885 INFO: Extending PYTHONPATH with paths
['d:\\code\\Python\\pyinstaller', 'd:\\code\\Python\\pyinstaller']
886 INFO: checking Analysis
887 INFO: Building Analysis because Analysis-00.toc is non existent
888 INFO: Initializing module dependency graph...
890 INFO: Initializing module graph hooks...
899 INFO: Analyzing base_library.zip ...
6225 INFO: Processing pre-find module path hook   distutils
11387 INFO: running Analysis Analysis-00.toc
12012 INFO: Caching module hooks...
12022 INFO: Analyzing d:\code\Python\pyinstaller\helloworld.py
12027 INFO: Loading module hooks...
12028 INFO: Loading module hook "hook-encodings.py"...
12395 INFO: Loading module hook "hook-xml.py"...
13507 INFO: Loading module hook "hook-pydoc.py"...
13508 INFO: Loading module hook "hook-distutils.py"...
13606 INFO: Looking for ctypes DLLs
13662 INFO: Analyzing run-time hooks ...
13677 INFO: Looking for dynamic libraries
13894 INFO: Looking for eggs
13895 INFO: Using Python library C:\WINDOWS\system32\python34.dll
13895 INFO: Found binding redirects:
[]
13915 INFO: Warnings written to d:\code\Python\pyinstaller\build\helloworld\warn-helloworld.txt
14035 INFO: Graph cross-reference written to d:\code\Python\pyinstaller\build\helloworld\xref-helloworld.html
14287 INFO: checking PYZ
14287 INFO: Building PYZ because PYZ-00.toc is non existent
14288 INFO: Building PYZ (ZlibArchive) d:\code\Python\pyinstaller\build\helloworld\PYZ-00.pyz
15836 INFO: Building PYZ (ZlibArchive) d:\code\Python\pyinstaller\build\helloworld\PYZ-00.pyz completed successfully.
15883 INFO: checking PKG
15884 INFO: Building PKG because PKG-00.toc is non existent
15884 INFO: Building PKG (CArchive) PKG-00.pkg
18528 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
18536 INFO: Bootloader D:\program\Python34\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
18537 INFO: checking EXE
18537 INFO: Building EXE because EXE-00.toc is non existent
18538 INFO: Building EXE from EXE-00.toc
18538 INFO: Appending archive to EXE d:\code\Python\pyinstaller\dist\helloworld.exe
18548 INFO: Building EXE from EXE-00.toc completed successfully.

生成文件:


新聞標(biāo)題:創(chuàng)新互聯(lián)Python教程:python如何編譯成exe
分享URL:http://m.5511xx.com/article/coseses.html