python3打包脚本
安装pip
python3版本默认没有安装pip。
复制get-pip.py的内容:https://bootstrap.pypa.io/get-pip.py
在python环境下运行。
C:\python36>python.exe get-pip.py
Collecting pip
Downloading pip-9.0.3-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 42kB/s
Collecting wheel
Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
100% |████████████████████████████████| 51kB 44kB/s
Installing collected packages: pip, wheel
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Successfully uninstalled pip-9.0.1
Successfully installed pip-9.0.3 wheel-0.30.0
安装pyinstaller
可以看到pip文件是最新安装的。
C:\python36>cd Scripts
C:\python36\Scripts>dir
驱动器 C 中的卷是 OS
卷的序列号是 509C-E5D1
C:\python36\Scripts 的目录
2018/03/23 13:20 <DIR> .
2018/03/23 13:20 <DIR> ..
2018/03/23 11:11 89,449 easy_install-3.6.exe
2018/03/23 11:11 89,449 easy_install.exe
2018/03/23 13:20 89,421 pip.exe
2018/03/23 13:20 89,421 pip3.6.exe
2018/03/23 13:20 89,421 pip3.exe
2018/03/23 13:20 89,428 wheel.exe
6 个文件 536,589 字节
2 个目录 65,916,514,304 可用字节
使用pip安装pyinstaller
C:\python36\Scripts>pip3 install pyinstaller
Collecting pyinstaller
Downloading PyInstaller-3.3.1.tar.gz (3.5MB)
100% |████████████████████████████████| 3.5MB 36kB/s
Requirement already satisfied: setuptools in c:\python36\lib\site-packages (from pyinstaller)
Collecting pefile>=2017.8.1 (from pyinstaller)
Downloading pefile-2017.11.5.tar.gz (61kB)
100% |████████████████████████████████| 71kB 46kB/s
Collecting macholib>=1.8 (from pyinstaller)
Downloading macholib-1.9-py2.py3-none-any.whl (40kB)
100% |████████████████████████████████| 40kB 20kB/s
Collecting future (from pyinstaller)
Downloading future-0.16.0.tar.gz (824kB)
100% |████████████████████████████████| 829kB 44kB/s
Collecting pypiwin32 (from pyinstaller)
Downloading pypiwin32-223-py3-none-any.whl
Collecting altgraph>=0.15 (from macholib>=1.8->pyinstaller)
Downloading altgraph-0.15-py2.py3-none-any.whl
Collecting pywin32>=223 (from pypiwin32->pyinstaller)
Downloading pywin32-223-cp36-cp36m-win32.whl (8.3MB)
100% |████████████████████████████████| 8.3MB 42kB/s
Building wheels for collected packages: pyinstaller, pefile, future
Running setup.py bdist_wheel for pyinstaller ... done
Stored in directory: C:\Users\i01007600138\AppData\Local\pip\Cache\wheels\2f\f8\8e\d8ee9b359f487a8488380f0b522d81fa5ee01956161d41b72e
Running setup.py bdist_wheel for pefile ... done
Stored in directory: C:\Users\i01007600138\AppData\Local\pip\Cache\wheels\30\34\1d\5f4e14feee63c615a1ae25c211b21237a6a74c1c4fb6639842
Running setup.py bdist_wheel for future ... done
Stored in directory: C:\Users\i01007600138\AppData\Local\pip\Cache\wheels\c2\50\7c\0d83b4baac4f63ff7a765bd16390d2ab43c93587fac9d6017a
Successfully built pyinstaller pefile future
Installing collected packages: future, pefile, altgraph, macholib, pywin32, pypiwin32, pyinstaller
Successfully installed altgraph-0.15 future-0.16.0 macholib-1.9 pefile-2017.11.5 pyinstaller-3.3.1 pypiwin32-223 pywin32-223
打包脚本
C:\python36\Scripts>pyinstaller -w c:/python36/nhrp.py
260 INFO: PyInstaller: 3.3.1
260 INFO: Python: 3.6.4
263 INFO: Platform: Windows-10-10.0.15063-SP0
267 INFO: wrote C:\python36\Scripts\nhrp.spec
272 INFO: UPX is not available.
274 INFO: Extending PYTHONPATH with paths
['c:\python36', 'C:\python36\Scripts']
274 INFO: checking Analysis
276 INFO: Building Analysis because out00-Analysis.toc is non existent
280 INFO: Initializing module dependency graph...
285 INFO: Initializing module graph hooks...
288 INFO: Analyzing base_library.zip ...
3665 INFO: running Analysis out00-Analysis.toc
3682 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\python36\python.exe
3958 WARNING: lib not found: api-ms-win-crt-process-l1-1-0.dll dependency of c:\python36\python36.dll
3985 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\python36\python36.dll
4596 INFO: Caching module hooks...
4601 INFO: Analyzing c:\python36\nhrp.py
4626 INFO: Loading module hooks...
4627 INFO: Loading module hook "hook-encodings.py"...
4793 INFO: Loading module hook "hook-pydoc.py"...
4794 INFO: Loading module hook "hook-xml.py"...
5043 INFO: Looking for ctypes DLLs
5043 INFO: Analyzing run-time hooks ...
5053 INFO: Looking for dynamic libraries
5102 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\python36\DLLs_ssl.pyd
5165 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\python36\DLLs_hashlib.pyd
5211 INFO: Looking for eggs
5211 INFO: Using Python library c:\python36\python36.dll
5213 INFO: Found binding redirects:
[]
5227 INFO: Warnings written to C:\python36\Scripts\build\nhrp\warnnhrp.txt
5278 INFO: Graph cross-reference written to C:\python36\Scripts\build\nhrp\xref-nhrp.html
5297 INFO: checking PYZ
5298 INFO: Building PYZ because out00-PYZ.toc is non existent
5299 INFO: Building PYZ (ZlibArchive) C:\python36\Scripts\build\nhrp\out00-PYZ.pyz
5814 INFO: Building PYZ (ZlibArchive) C:\python36\Scripts\build\nhrp\out00-PYZ.pyz completed successfully.
5819 INFO: checking PKG
5820 INFO: Building PKG because out00-PKG.toc is non existent
5821 INFO: Building PKG (CArchive) out00-PKG.pkg
5838 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
5839 INFO: Bootloader c:\python36\lib\site-packages\PyInstaller\bootloader\Windows-32bit\runw.exe
5840 INFO: checking EXE
5843 INFO: Building EXE because out00-EXE.toc is non existent
5846 INFO: Building EXE from out00-EXE.toc
5848 INFO: Appending archive to EXE C:\python36\Scripts\build\nhrp\nhrp.exe
5851 INFO: Building EXE from out00-EXE.toc completed successfully.
5854 INFO: checking COLLECT
5854 INFO: Building COLLECT because out00-COLLECT.toc is non existent
5856 INFO: Building COLLECT out00-COLLECT.toc
5951 INFO: Updating manifest in C:\Users\i01007600138\AppData\Roaming\pyinstaller\bincache00_py36_32bit\python36.dll
5952 INFO: Updating resource type 24 name 2 language 1033
10037 INFO: Updating manifest in C:\Users\i01007600138\AppData\Roaming\pyinstaller\bincache00_py36_32bit_ssl.pyd
10038 INFO: Updating resource type 24 name 2 language 1033
10062 INFO: Updating manifest in C:\Users\i01007600138\AppData\Roaming\pyinstaller\bincache00_py36_32bit\unicodedata.pyd
10063 INFO: Updating resource type 24 name 2 language 1033
10079 INFO: Updating manifest in C:\Users\i01007600138\AppData\Roaming\pyinstaller\bincache00_py36_32bit\pyexpat.pyd
10080 INFO: Updating resource type 24 name 2 language 1033
10099 INFO: Updating manifest in C:\Users\i01007600138\AppData\Roaming\pyinstaller\bincache00_py36_32bit_hashlib.pyd
10100 INFO: Updating resource type 24 name 2 language 1033
10118 INFO: Updating manifest in C:\Users\i01007600138\AppData\Roaming\pyinstaller\bincache00_py36_32bit_bz2.pyd
10120 INFO: Updating resource type 24 name 2 language 1033
10133 INFO: Updating manifest in C:\Users\i01007600138\AppData\Roaming\pyinstaller\bincache00_py36_32bit_lzma.pyd
10134 INFO: Updating resource type 24 name 2 language 1033
10149 INFO: Updating manifest in C:\Users\i01007600138\AppData\Roaming\pyinstaller\bincache00_py36_32bit_socket.pyd
10150 INFO: Updating resource type 24 name 2 language 1033
10164 INFO: Updating manifest in C:\Users\i01007600138\AppData\Roaming\pyinstaller\bincache00_py36_32bit\select.pyd
10165 INFO: Updating resource type 24 name 2 language 1033
10185 INFO: Building COLLECT out00-COLLECT.toc completed successfully.
在dist文件夹下已经生成了exe文件。
C:\python36\Scripts\dist>cd nhrp
C:\python36\Scripts\dist\nhrp>dir
驱动器 C 中的卷是 OS 卷的序列号是 509C-E5D1
C:\python36\Scripts\dist\nhrp 的目录
2018/03/23 13:33 <DIR> .
2018/03/23 13:33 <DIR> ..
2018/03/23 13:33 19,864 api-ms-win-core-console-l1-1-0.dll
2018/03/23 13:33 19,360 api-ms-win-core-datetime-l1-1-0.dll
2018/03/23 13:33 19,344 api-ms-win-core-debug-l1-1-0.dll
2018/03/23 13:33 19,376 api-ms-win-core-errorhandling-l1-1-0.dll
2018/03/23 13:33 22,928 api-ms-win-core-file-l1-1-0.dll
2018/03/23 13:33 19,344 api-ms-win-core-file-l1-2-0.dll
2018/03/23 13:33 19,336 api-ms-win-core-file-l2-1-0.dll
2018/03/23 13:33 19,352 api-ms-win-core-handle-l1-1-0.dll
2018/03/23 13:33 19,856 api-ms-win-core-heap-l1-1-0.dll
2018/03/23 13:33 19,880 api-ms-win-core-interlocked-l1-1-0.dll
2018/03/23 13:33 19,888 api-ms-win-core-libraryloader-l1-1-0.dll
2018/03/23 13:33 21,936 api-ms-win-core-localization-l1-2-0.dll
2018/03/23 13:33 19,864 api-ms-win-core-memory-l1-1-0.dll
2018/03/23 13:33 19,360 api-ms-win-core-namedpipe-l1-1-0.dll
2018/03/23 13:33 20,424 api-ms-win-core-processenvironment-l1-1-0.dll
2018/03/23 13:33 21,432 api-ms-win-core-processthreads-l1-1-0.dll
2018/03/23 13:33 19,896 api-ms-win-core-processthreads-l1-1-1.dll
2018/03/23 13:33 18,840 api-ms-win-core-profile-l1-1-0.dll
2018/03/23 13:33 18,856 api-ms-win-core-rtlsupport-l1-1-0.dll
2018/03/23 13:33 19,352 api-ms-win-core-string-l1-1-0.dll
2018/03/23 13:33 21,392 api-ms-win-core-synch-l1-1-0.dll
2018/03/23 13:33 19,856 api-ms-win-core-synch-l1-2-0.dll
2018/03/23 13:33 20,376 api-ms-win-core-sysinfo-l1-1-0.dll
2018/03/23 13:33 19,360 api-ms-win-core-timezone-l1-1-0.dll
2018/03/23 13:33 19,344 api-ms-win-core-util-l1-1-0.dll
2018/03/23 13:33 23,448 api-ms-win-crt-convert-l1-1-0.dll
2018/03/23 13:33 19,880 api-ms-win-crt-environment-l1-1-0.dll
2018/03/23 13:33 21,408 api-ms-win-crt-filesystem-l1-1-0.dll
2018/03/23 13:33 20,360 api-ms-win-crt-heap-l1-1-0.dll
2018/03/23 13:33 19,856 api-ms-win-crt-locale-l1-1-0.dll
2018/03/23 13:33 30,088 api-ms-win-crt-math-l1-1-0.dll
2018/03/23 13:33 23,952 api-ms-win-crt-runtime-l1-1-0.dll
2018/03/23 13:33 25,488 api-ms-win-crt-stdio-l1-1-0.dll
2018/03/23 13:33 25,488 api-ms-win-crt-string-l1-1-0.dll
2018/03/23 13:33 21,896 api-ms-win-crt-time-l1-1-0.dll
2018/03/23 13:33 19,864 api-ms-win-crt-utility-l1-1-0.dll
2018/03/23 13:33 732,544 base_library.zip
2018/03/23 13:33 1,417,359 nhrp.exe
2018/03/23 13:33 1,027 nhrp.exe.manifest
2018/03/23 13:33 157,184 pyexpat.pyd
2018/03/23 13:33 3,291,136 python36.dll
2018/03/23 13:33 16,384 select.pyd
2018/03/23 13:33 1,150,776 ucrtbase.dll
2018/03/23 13:33 888,832 unicodedata.pyd
2018/03/23 13:33 83,784 VCRUNTIME140.dll
2018/03/23 13:33 71,168 _bz2.pyd
2018/03/23 13:33 1,114,112 _hashlib.pyd
2018/03/23 13:33 176,640 _lzma.pyd
2018/03/23 13:33 54,784 _socket.pyd
2018/03/23 13:33 1,452,544 _ssl.pyd
50 个文件 11,358,818 字节
2 个目录 65,685,147,648 可用字节
双击exe文件,即可执行脚本。
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341