国产成人AV无码一二三区,少女1到100集,国产精品久久久久精品综合紧,巜公妇之诱感肉欲HD在线播放

文章 > Python常见问题 > python如何编译成exe

python如何编译成exe

Python

头像

(*-*)浩

2020-12-11 11:46:3528141浏览 · 0收藏 · 0评论

Python 程序都是脚本的方式,一般是在解析器里运行,如果要发布出去,需要提前安装解析器才可以运行,为了在 Windows 里方便发布,只要点击一个 EXE 文件运行,并且打包所需要库文件,这样发布给用户使用就会更方便。

PyInstaller

PyInstaller 是一个十分有用的第三方库,可以用来打包 python 应用程序,打包完的程序就可以在没有安装 Python 解释器的机器上运行了。

更多相关知识,可以参考这篇文章:《python如何编译成exe文件

它能够在 Windows、Linux、 Mac OS X 等操作系统下将 Python 源文件打包,通过对源文件打包, Python 程序可以在没有安装 Python 的环境中运行,也可以作为一个 独立文件方便传递和管理。

PyInstaller 支持 Python 2.7 / 3.4-3.7??梢栽?Windows、Mac OS X 和 Linux 上使用,但是并不是跨平台的,而是说你要是希望打包成 .exe 文件,需要在 Windows 系统上运行 PyInstaller 进行打包工作。

下面我们以 Windows 为例来进行程序的打包工作。

安装

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

使用

pyinstaller -F helloworld.py

其中,-F 表示打包成单独的 .exe 文件,这时生成的 .exe 文件会比较大,而且运行速度回较慢。仅仅一个 helloworld 程序,生成的文件就 5MB 大。

另外,使用 -i 还可以指定可执行文件的图标;

-w 表示去掉控制台窗口,这在 GUI 界面时非常有用。不过如果是命令行程序的话那就把这个选项删除吧!

PyInstaller 会对脚本进行解析,并做出如下动作:

1、在脚本目录生成 helloworld.spec 文件;

2、创建一个 build 目录;

3、写入一些日志文件和中间流程文件到 build 目录;

4、创建 dist 目录;

5、生成可执行文件到 dist 目录;

执行流程:

$ 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.

生成文件:

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

杨思敏电影| 免费观看B站刺激战场2023| 黑色董丝包臀紧身连衣裙| 伦理《少妇的滋味》完整版| 0.伦理《少妇的滋味》完整版| 美女和帅哥一起努力生产豆浆的视.| 美女热舞| 成全高清免费完整观看| 欧美| 续父开续女包小芳的小说破| 小天马| 老头跪在两腿之间吃奶| DK战队| 懵懂少女的挨日常TXT百度云资..| 老师穿白色双开真丝旗袍怎么穿| 狗配人的大片视频大全| 女生的全身照曝光| 白日梦我电视剧免费观看完整版| 种马农场(6P)--骑当千菁T..| 《訾花交换做爰》| 种马农场(6P)--骑当千菁T..| 蜜桃成熟时2| 《厨房激战5》完整版在线观看| 《艳乳欲乱2》动漫| 父母儿女媳妇一起来| 国外黄冈站刺激战场| 强伦女教师2:伦理| 被C的时候要喊什么骚一点| 《黑人性奴2》免费观看| 妈妈可以帮儿子解决心理需要| 主人请好好疼爱里面动画第二季 | LIBRA| 混合交换5HD| 夜生活在线观看免费观看电视剧 | 《酒店激战》动漫1-5集免费观...| 一家乱战1-13集小说免费阅读| 日亚M码是日本的还是中国的| 免费高清在线观看免费的PPT软..| 老阿姨高清免费观看电视剧| 免费的行情网站WWW下载大全 | 《饥饿妻子》完整版在线观看