关于

Python学习笔记(15)-Python代码转换为exe可执行程序详解_熊猫大哥大-CSDN博客_python转化为exe

Python 将.py转换为.exe详解_tangdaxue43的博客-CSDN博客_py转换成exe

的一些小心得;

下载PyInstaller

pip install pyinstaller

结果如下:意思是已经装上了。

下载pywin32

先看看python目录C:\Users\DELL\AppData\Local\Programs\Python\Python39\Scripts里有没有pywin32_postinstall.py,如果有直接在这个目录下执行:

python pywin32_postinstall.py -install

再看看目录里的内容,确定有没有需要的pyinstaller.exe,执行ls,结果如下图:

ls

可以把这个pyinstaller.exe复制出来到任意文件夹,直接用,保证pyinstaller.exe和带转换的.py同在一个文件夹即可。

开始转换

自己编写一个.py文件,其实txt文件就可以,把.txt改成.py重命名。和pyinstaller.exe放在一个文件夹里。

print('hello world!')

input()

执行(exe文件名前面的.\是执行的意思),注意文件名称。

.\pyinstaller.exe -F .\helloworld.py

PS D:\WORK> .\pyinstaller.exe -F .\helloworld.py
96 INFO: PyInstaller: 4.7
96 INFO: Python: 3.9.6
104 INFO: Platform: Windows-10-10.0.19044-SP0
104 INFO: wrote D:\WORK\helloworld.spec
108 INFO: UPX is not available.
113 INFO: Extending PYTHONPATH with paths
['D:\\WORK']
591 INFO: checking Analysis
591 INFO: Building Analysis because Analysis-00.toc is non existent
591 INFO: Initializing module dependency graph...
594 INFO: Caching module graph hooks...
616 INFO: Analyzing base_library.zip ...
3492 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
3493 INFO: distutils: retargeting to non-venv dir 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib'
6888 INFO: Caching module dependency graph...
7023 INFO: running Analysis Analysis-00.toc
7036 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executablerequired by C:\Users\DELL\AppData\Local\Programs\Python\Python39\python.exe
7107 INFO: Analyzing D:\WORK\Technology Support\From LiangHe\New OTA\ota\ComReader\helloworld.py
7112 INFO: Processing module hooks...
7112 INFO: Loading module hook 'hook-difflib.py' from 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
7114 INFO: Loading module hook 'hook-distutils.py' from 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
7114 INFO: Loading module hook 'hook-distutils.util.py' from 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
7115 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
7196 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
7198 INFO: Loading module hook 'hook-lib2to3.py' from 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
7262 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
7264 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
7265 INFO: Loading module hook 'hook-sysconfig.py' from 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
7267 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
7268 INFO: Loading module hook 'hook-xml.py' from 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
7368 INFO: Loading module hook 'hook-_tkinter.py' from 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
7552 INFO: checking Tree
7552 INFO: Building Tree because Tree-00.toc is non existent
7554 INFO: Building Tree Tree-00.toc
7665 INFO: checking Tree
7665 INFO: Building Tree because Tree-01.toc is non existent
7666 INFO: Building Tree Tree-01.toc
7764 INFO: checking Tree
7764 INFO: Building Tree because Tree-02.toc is non existent
7764 INFO: Building Tree Tree-02.toc
7779 INFO: Looking for ctypes DLLs
7789 INFO: Analyzing run-time hooks ...
7790 INFO: Including run-time hook 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
7798 INFO: Including run-time hook 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
7805 INFO: Including run-time hook 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
7814 INFO: Looking for dynamic libraries
8022 INFO: Looking for eggs
8022 INFO: Using Python library C:\Users\DELL\AppData\Local\Programs\Python\Python39\python39.dll
8023 INFO: Found binding redirects:
[]
8030 INFO: Warnings written to D:\WORK\build\helloworld\warn-helloworld.txt
8059 INFO: Graph cross-reference written to D:\WORK\build\helloworld\xref-helloworld.html
8068 INFO: checking PYZ
8068 INFO: Building PYZ because PYZ-00.toc is non existent
8069 INFO: Building PYZ (ZlibArchive) D:\WORK\build\helloworld\PYZ-00.pyz
8432 INFO: Building PYZ (ZlibArchive) D:\WORK\build\helloworld\PYZ-00.pyz completed successfully.
8444 INFO: checking PKG
8444 INFO: Building PKG because PKG-00.toc is non existent
8445 INFO: Building PKG (CArchive) helloworld.pkg
9684 INFO: Building PKG (CArchive) helloworld.pkg completed successfully.
9686 INFO: Bootloader C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
9686 INFO: checking EXE
9686 INFO: Building EXE because EXE-00.toc is non existent
9686 INFO: Building EXE from EXE-00.toc
9686 INFO: Copying bootloader EXE to D:\WORK\dist\helloworld.exe
9734 INFO: Copying icon to EXE
9735 INFO: Copying icons from ['C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
9780 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
9780 INFO: Writing RT_ICON 1 resource with 3752 bytes
9781 INFO: Writing RT_ICON 2 resource with 2216 bytes
9789 INFO: Writing RT_ICON 3 resource with 1384 bytes
9789 INFO: Writing RT_ICON 4 resource with 37019 bytes
9790 INFO: Writing RT_ICON 5 resource with 9640 bytes
9790 INFO: Writing RT_ICON 6 resource with 4264 bytes
9791 INFO: Writing RT_ICON 7 resource with 1128 bytes
9793 INFO: Copying 0 resources to EXE
9793 INFO: Emedding manifest in EXE
9794 INFO: Updating manifest in D:\WORK\dist\helloworld.exe
9839 INFO: Updating resource type 24 name 1 language 0
9841 INFO: Appending PKG archive to EXE
10839 INFO: Building EXE from EXE-00.toc completed successfully.

在dist文件夹里有exe文件:

双击运行显示结果:

python文件(.py)转换为可执行文件(.exe)操作相关推荐

  1. 如何将Python文件.py打包成.exe可执行程序(最简教程吗)

    相信对python有过学习的朋友都知道可以用IDLE编写并跑一跑python,但是如何做到别人电脑没有装python的情况下运行python的脚本呢?(看标题) 这里简单提一下.exe 可执行程序 . ...

  2. python文件打包成可执行文件exe的两种方法

    python 可以做网站应用,也可以做客户端应用.但是客户端应用需要运行 py 脚本,如果用户不懂 python 就是一件比较麻烦的事情.幸好 pyton 有第三方模块可以将脚本可以转成 exe 执行 ...

  3. .pyc文件还原.py文件_Python文件.py转换为.exe可执行程序,制作.exe文件图标

    当大家想要将自己写的Python程序对别人进行展示的时候,你是否还是打开你的Pycharm进行运行展示? 假如是专业的人士看你的代码,一眼就能看懂你的代码,而其实我们可以不需要给代码,利用pyinst ...

  4. Python 将.py转换为.exe详解

    本文是由@熊猫大哥大的博客修改而来(所以就不能说是"原创"了) 原博客链接:Python学习笔记(15)-Python代码转换为exe可执行程序详解(下面会提到本文与其的一点不同) ...

  5. python文件封装成jar_【Python】Python文件打包为可执行文件

    之前写的用于创建.链接Jenkins slave脚本是使用Python实现的,为了使未安装Python环境的伙伴也可以直接使用,故需要将其可直接执行的exe可执行文件. 一.安装pyinsatller ...

  6. python打包成二进制文件_pyinstall python文件打包成二进制exe文件

    pycharm + python3 + win7 1 pip install pyinstall  (官网) 2 准备 .py 文件 3 具体例子 from PyQt5.QtWidgets impor ...

  7. python 拆分pdf(有可执行文件exe)

    1.背景 被那些软件pdf拆分整气死了,今天用python写一份pdf拆分的代码. 2.代码:(计算机的可以去学习一下,自己改改) pdf_split.py from PyPDF2 import Pd ...

  8. Python文件.py||.pyi||.pyc||.pyo||.pyd等各种文件后缀区别(全面汇总)

    .py:这通常是您编写的输入源代码. .py3: Python3脚本(Python3脚本通常以.py而不是.py3结尾,很少使用) .pyc:这是编译好的字节码.如果您导入一个模块,python将生成 ...

  9. Anaconda安装完python文件.py不显示黄蓝图标

    下载安装完Anaconda之后,环境变量也配置完,python的各模块的,什么也都正常运行,但是:py文件显示的是文本文件的空白图标,这是要逼死强迫症的节奏啊! 如上图,环境变量已经配置完成. 如上图 ...

  10. python文件如何打包生成.exe文件?(打包教程)

    具体操作见:(我一直在学的也是这个课程,还凑合) 花了2万多买的Python教程全套,现在分享给大家,入门到精通(Python全栈开发教程)_哔哩哔哩_bilibili 大致步骤: 第一步: 先在cm ...

最新文章

  1. 关于三岔路口双车接力,这位同学把问题总算问清楚了
  2. 用cxf开发restful风格的WebService
  3. 树莓派摄像头基本操作
  4. ios 构建版本一直在处理中_iOS -打包上传成功,在构建版本一直刷不出来
  5. 仅坚持了9天:京东今日宣布暂停火车票代购业务
  6. 在.net 2.0 中执行分布式事务:隐式事务篇(SQL Server 与 Oracle)
  7. 奇迹世界服务器不响应,sun-奇迹世界 目前常见问题解决方法
  8. 第六次程序设计作业 计算器图型界面的设计
  9. mysql optimize 参数查看_Mysql High Performance:Optimize Setting
  10. logistic回归详解(二):损失函数(cost function)详解
  11. rsync同步目录及同步文件
  12. 《App 后台开发运维和架构实践》完整目录
  13. 基于redis的简易单点登录系统
  14. 独角兽云发卡系统源码下载
  15. 全球与中国电子柜锁市场深度研究分析报告
  16. 为什么要学数学、语文?还有英语!
  17. [python]微信公众号JS逆向
  18. CIMISS数据获取流程
  19. bboss ioc快速入门教程
  20. 使用Firefox+Tor+FoxyProxy+Noscript+IETab进行安全自由的网上冲浪

热门文章

  1. matlab 跳步,给定两个大整数u和v,它们分别有m和n位数字,且m≤n.用通常的乘法求uv的值需要O(mn)时间.可以将u和v.. - 上学吧找答案(手机版)...
  2. 微信公众号二维码在哪里看?如何查看自己的微信公众号二维码?
  3. word中px,pt,dpi,in,em,twip,emu之间的关系
  4. 什么是深拷贝与浅拷贝
  5. pandas+matplotlib——习题一
  6. 计算机科学与技术工程师职称考试试题,2018年下半年网络工程师考试下午试题及答案...
  7. 凯恩斯主义税收思想概述
  8. oracle驱动包下载
  9. MSTAR648方案遥控器配置
  10. java从键盘读入数据_关于Java中从键盘读入各种数据的方式