如何将 Python 程序打包成.exe 文件?

如何将 Python 程序打包成.exe 文件?

https://cloud.tencent.com/developer/news/318395

改文章介绍的不错.建议阅读原文.

 

python打包成.exe程序

https://blog.csdn.net/wickedvalley/article/details/79948199

 

 

我在使用过程中发生了错误:TypeError: an integer is required (got type bytes)

 

具体内容如下:

D:\RFExplorer-for-Python\Examples_USB>pyinstaller -F -w RFE_Sweep.py

80 INFO: PyInstaller: 3.5

80 INFO: Python: 3.8.0

80 INFO: Platform: Windows-10-10.0.16299-SP0

100 INFO: wrote D:\RFExplorer-for-Python\Examples_USB\RFE_Sweep.spec

100 INFO: UPX is not available.

109 INFO: Extending PYTHONPATH with paths

['D:\\RFExplorer-for-Python\\Examples_USB',

 'D:\\RFExplorer-for-Python\\Examples_USB']

109 INFO: checking Analysis

109 INFO: Building Analysis because Analysis-00.toc is non existent

109 INFO: Initializing module dependency graph...

109 INFO: Initializing module graph hooks...

109 INFO: Analyzing base_library.zip ...

6953 INFO: running Analysis Analysis-00.toc

6973 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable

  required by c:\users\guangyu\appdata\local\programs\python\python38\python.exe

7707 INFO: Caching module hooks...

7717 INFO: Analyzing D:\RFExplorer-for-Python\Examples_USB\RFE_Sweep.py

8250 INFO: Loading module hooks...

8250 INFO: Loading module hook "hook-encodings.py"...

8384 INFO: Loading module hook "hook-pydoc.py"...

8394 INFO: Loading module hook "hook-xml.py"...

8754 INFO: Looking for ctypes DLLs

8784 INFO: Analyzing run-time hooks ...

8784 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'

8794 INFO: Looking for dynamic libraries

8987 INFO: Looking for eggs

8987 INFO: Using Python library c:\users\guangyu\appdata\local\programs\python\python38\python38.dll

8987 INFO: Found binding redirects:

[]

8997 INFO: Warnings written to D:\RFExplorer-for-Python\Examples_USB\build\RFE_Sweep\warn-RFE_Sweep.txt

9037 INFO: Graph cross-reference written to D:\RFExplorer-for-Python\Examples_USB\build\RFE_Sweep\xref-RFE_Sweep.html

9087 INFO: checking PYZ

9087 INFO: Building PYZ because PYZ-00.toc is non existent

9097 INFO: Building PYZ (ZlibArchive) D:\RFExplorer-for-Python\Examples_USB\build\RFE_Sweep\PYZ-00.pyz

Traceback (most recent call last):

  File "c:\users\guangyu\appdata\local\programs\python\python38\lib\runpy.py", line 192, in _run_module_as_main

    return _run_code(code, main_globals, None,

  File "c:\users\guangyu\appdata\local\programs\python\python38\lib\runpy.py", line 85, in _run_code

    exec(code, run_globals)

  File "C:\Users\guangyu\AppData\Local\Programs\Python\Python38\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>

  File "c:\users\guangyu\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 111, in run

    run_build(pyi_config, spec_file, **vars(args))

  File "c:\users\guangyu\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build

    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)

  File "c:\users\guangyu\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main

    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))

  File "c:\users\guangyu\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build

    exec(code, spec_namespace)

  File "D:\RFExplorer-for-Python\Examples_USB\RFE_Sweep.spec", line 18, in <module>

    pyz = PYZ(a.pure, a.zipped_data,

  File "c:\users\guangyu\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 98, in __init__

    self.__postinit__()

  File "c:\users\guangyu\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__

    self.assemble()

  File "c:\users\guangyu\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 128, in assemble

    self.code_dict = {

  File "c:\users\guangyu\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 129, in <dictcomp>

    key: strip_paths_in_code(code)

  File "c:\users\guangyu\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\utils.py", line 652, in strip_paths_in_code

    consts = tuple(

  File "c:\users\guangyu\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\utils.py", line 653, in <genexpr>

    strip_paths_in_code(const_co, new_filename)

  File "c:\users\guangyu\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\utils.py", line 660, in strip_paths_in_code

    return code_func(co.co_argcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize,

TypeError: an integer is required (got type bytes)

 

通过:https://blog.csdn.net/chen_soldier/article/details/102667201的方法解决掉:

具体操作就是cmd 执行 >pip install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz

安装完后就可以了.

 

使用参数上: -F是只生成一个文件;-w是没有控制台的窗口程序;

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

零点零一

您的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值