使用pyinstaller打包有个好处就是所有依赖都打包进去了,可以随意把文件移动到别的电脑上使用

安装

pip install pyinstaller

新建一个demo.py文件

#!/usr/bin/python3
# -*- coding: utf-8 -*-
print("hello world")

打开cmd或powershell

PS D:\build> pyinstaller.exe -F -c .\demo.py

 INFO: PyInstaller: 3.3.
INFO: Python: 3.6.
INFO: Platform: Windows--10.0.-SP0
INFO: wrote D:\build\demo.spec
INFO: UPX is not available.
INFO: Extending PYTHONPATH with paths
['D:\\build', 'D:\\build']
INFO: checking Analysis
INFO: Building Analysis because out00-Analysis.toc is non existent
INFO: Initializing module dependency graph...
INFO: Initializing module graph hooks...
INFO: Analyzing base_library.zip ...
INFO: running Analysis out00-Analysis.toc
INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\downtown\appdata\local\programs\python\python36\python.exe
WARNING: lib not found: api-ms-win-crt-heap-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python.exe
WARNING: lib not found: api-ms-win-crt-runtime-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python.exe
WARNING: lib not found: api-ms-win-crt-stdio-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python.exe
WARNING: lib not found: api-ms-win-crt-locale-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python.exe
WARNING: lib not found: api-ms-win-crt-math-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python.exe
WARNING: lib not found: api-ms-win-crt-heap-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python36.dll
WARNING: lib not found: api-ms-win-crt-runtime-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python36.dll
WARNING: lib not found: api-ms-win-crt-environment-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python36.dll
WARNING: lib not found: api-ms-win-crt-convert-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python36.dll
WARNING: lib not found: api-ms-win-crt-locale-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python36.dll
WARNING: lib not found: api-ms-win-crt-time-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python36.dll
WARNING: lib not found: api-ms-win-crt-stdio-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python36.dll
WARNING: lib not found: api-ms-win-crt-process-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python36.dll
WARNING: lib not found: api-ms-win-crt-conio-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python36.dll
WARNING: lib not found: api-ms-win-crt-string-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python36.dll
WARNING: lib not found: api-ms-win-crt-math-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python36.dll
WARNING: lib not found: api-ms-win-crt-filesystem-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\python36.dll
WARNING: lib not found: api-ms-win-crt-runtime-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\VCRUNTIME140.dll
WARNING: lib not found: api-ms-win-crt-stdio-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\VCRUNTIME140.dll
WARNING: lib not found: api-ms-win-crt-convert-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\VCRUNTIME140.dll
WARNING: lib not found: api-ms-win-crt-string-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\VCRUNTIME140.dll
WARNING: lib not found: api-ms-win-crt-heap-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\VCRUNTIME140.dll
INFO: Caching module hooks...
INFO: Analyzing D:\build\demo.py
INFO: Loading module hooks...
INFO: Loading module hook "hook-encodings.py"...
INFO: Loading module hook "hook-pydoc.py"...
INFO: Loading module hook "hook-xml.py"...
INFO: Looking for ctypes DLLs
INFO: Analyzing run-time hooks ...
INFO: Looking for dynamic libraries
WARNING: lib not found: api-ms-win-crt-heap-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_ssl.pyd
WARNING: lib not found: api-ms-win-crt-runtime-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_ssl.pyd
WARNING: lib not found: api-ms-win-crt-utility-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_ssl.pyd
WARNING: lib not found: api-ms-win-crt-stdio-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_ssl.pyd
WARNING: lib not found: api-ms-win-crt-environment-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_ssl.pyd
WARNING: lib not found: api-ms-win-crt-convert-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_ssl.pyd
WARNING: lib not found: api-ms-win-crt-time-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_ssl.pyd
WARNING: lib not found: api-ms-win-crt-filesystem-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_ssl.pyd
WARNING: lib not found: api-ms-win-crt-conio-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_ssl.pyd
WARNING: lib not found: api-ms-win-crt-string-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_ssl.pyd
WARNING: lib not found: api-ms-win-crt-runtime-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\unicodedata.pyd
WARNING: lib not found: api-ms-win-crt-stdio-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\unicodedata.pyd
WARNING: lib not found: api-ms-win-crt-string-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\unicodedata.pyd
WARNING: lib not found: api-ms-win-crt-heap-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\pyexpat.pyd
WARNING: lib not found: api-ms-win-crt-runtime-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\pyexpat.pyd
WARNING: lib not found: api-ms-win-crt-environment-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\pyexpat.pyd
WARNING: lib not found: api-ms-win-crt-stdio-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\pyexpat.pyd
WARNING: lib not found: api-ms-win-crt-string-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\pyexpat.pyd
WARNING: lib not found: api-ms-win-crt-heap-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
WARNING: lib not found: api-ms-win-crt-runtime-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
WARNING: lib not found: api-ms-win-crt-utility-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
WARNING: lib not found: api-ms-win-crt-stdio-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
WARNING: lib not found: api-ms-win-crt-environment-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
WARNING: lib not found: api-ms-win-crt-convert-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
WARNING: lib not found: api-ms-win-crt-time-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
WARNING: lib not found: api-ms-win-crt-conio-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
WARNING: lib not found: api-ms-win-crt-string-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
WARNING: lib not found: api-ms-win-crt-runtime-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\select.pyd
WARNING: lib not found: api-ms-win-crt-runtime-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_bz2.pyd
WARNING: lib not found: api-ms-win-crt-math-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_bz2.pyd
WARNING: lib not found: api-ms-win-crt-stdio-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_bz2.pyd
WARNING: lib not found: api-ms-win-crt-string-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_bz2.pyd
WARNING: lib not found: api-ms-win-crt-heap-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_bz2.pyd
WARNING: lib not found: api-ms-win-crt-runtime-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_lzma.pyd
WARNING: lib not found: api-ms-win-crt-heap-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_lzma.pyd
WARNING: lib not found: api-ms-win-crt-runtime-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_socket.pyd
WARNING: lib not found: api-ms-win-crt-string-l1--.dll dependency of c:\users\downtown\appdata\local\programs\python\python36\DLLs\_socket.pyd
INFO: Looking for eggs
INFO: Using Python library c:\users\downtown\appdata\local\programs\python\python36\python36.dll
INFO: Found binding redirects:
[]
INFO: Warnings written to D:\build\build\demo\warndemo.txt
INFO: Graph cross-reference written to D:\build\build\demo\xref-demo.html
INFO: checking PYZ
INFO: Building PYZ because out00-PYZ.toc is non existent
INFO: Building PYZ (ZlibArchive) D:\build\build\demo\out00-PYZ.pyz
INFO: Building PYZ (ZlibArchive) D:\build\build\demo\out00-PYZ.pyz completed successfully.
INFO: checking PKG
INFO: Building PKG because out00-PKG.toc is non existent
INFO: Building PKG (CArchive) out00-PKG.pkg
INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
INFO: Bootloader c:\users\downtown\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
INFO: checking EXE
INFO: Building EXE because out00-EXE.toc is non existent
INFO: Building EXE from out00-EXE.toc
INFO: Appending archive to EXE D:\build\dist\demo.exe
INFO: Building EXE from out00-EXE.toc completed successfully.
PS D:\build>

打开 dist 目录会看到已经生成了demo.exe

windows下使用pyinstaller把python文件打包成exe可执行文件的更多相关文章

  1. PyQt(Python+Qt)学习随笔:windows下使用pyinstaller将PyQt文件打包成exe可执行文件

    专栏:Python基础教程目录 专栏:使用PyQt开发图形界面Python应用 专栏:PyQt入门学习 老猿Python博文目录 在<windows下使用pyinstaller将多个目录的Pyt ...

  2. windows下使用pyinstaller将多个目录的Python文件打包成exe可执行文件

    专栏:Python基础教程目录 专栏:使用PyQt开发图形界面Python应用 专栏:PyQt入门学习 老猿Python博文目录 一.引言 需要将一个工程涉及两个目录的模块文件打包成exe,打包环境如 ...

  3. windows下如何将Python文件打包成.exe可执行文件

    在使用Python做开发的时候,时不时会给自己编写了一些小工具辅助自己的工作,但是由于开发依赖环境问题,多数只能在自己电脑上运行,拿到其它电脑后就没法运行了.这显得很不方便,不符合我们的初衷,那么有没 ...

  4. win7下用PyInstaller把Python代码打包成exe文件

    2013-11-05 22:02:14|   1.安装 使用PyInstaller需要安装PyWin32. 下载与Python对应的PyInstaller版本,解压后就算安装好了. 例如,安装了PyI ...

  5. 用pyinstaller把python代码打包成exe可执行文件

    优点: 1. pyinstaller 是跨平台的可以用在linux和windows系统上 2. 操作非常简单,几个命令就搞定了,这个比py2exe容易用多了 缺点: 1. 打包后的体积过大,因为要带p ...

  6. 将python文件打包成exe可执行文件

    操作系统:win8-64位 python版本:3.5 pyInstaller版本:3.2(下载地址:http://www.pyinstaller.org/) pywin32版本:pywin32-219 ...

  7. 将Python项目打包成EXE可执行文件(单文件,多文件,包含图片)

    解决 将Python项目打包成EXE可执行文件(单文件,多文件,包含图片) 1.当我们写了一个Python的项目时,特别是一个GUI项目,我们特备希望它能成为一个在Windows系统可执行的EXE文件 ...

  8. 如何把py文件打包成exe可执行文件

    如何把py文件打包成exe可执行文件 1.安装 pip install pyinstaller 或者 pip install -i https://pypi.douban.com/simple pyi ...

  9. 关于python文件打包成exe的调试问题

    python文件使用pyinstaller打包的问题 常用pyinstaller相关命令 文件整体打包, 会自动打包相关依赖 pyinstaller -F file 分文件打包,只打包单个文件,其他文 ...

随机推荐

  1. day08 服务

    pasting ]注册电话的监听 tm.listen(new MyPhoneStateListener(), PhoneStateListener.LISTEN_CALL_STATE);     [4 ...

  2. Zookeeper中Session Timeout的那些事

    前言: RDS系统致力于MySQL数据的高可用,高可靠,高性能以及在线扩展功能,实现这些特性的主要逻辑功能都运行在管理服务器上,一旦管理服务器宕机,数据库的在线扩展功能/备份功能/故障恢复功能等都无从 ...

  3. python爬虫之真实世界中的网页解析

    Request和Response Request是我们平常浏览网页,向网站所在的服务器发起请求,而服务器收到请求后,返回给我们的回应就是Response,这种行为就称为HTTP协议,也就是客户端(浏览 ...

  4. db2 MON_GET_PKG_CACHE_STMT 表函数 抓取分析SQL

    MON_GET_PKG_CACHE_STMT 表函数 还可以使用 MON_GET_PKG_CACHE_STMT 表函数来查询当前 PACKAGE CACHE 中 SQL 语句(包括动态 SQL 和静态 ...

  5. ubuntu 搜狗输入法 在中断失效

    实测是更换了皮肤后,出现在中断输入故障,乱码.在其他界面可能是正常的,更换语言没用. killall fcitx输入法突然好了(根据网友所说,更改一堆东西貌似并没有什么用) 此时关闭输入法皮肤一切正常 ...

  6. spring boot拦截器WebMvcConfigurerAdapter,以及高版本的替换方案

    Springboot中静态资源和拦截器处理(踩了坑)   背景: 在项目中我使用了自定义的Filter 这时候过滤了很多路径,当然对静态资源我是直接放过去的,但是,还是出现了静态资源没办法访问到spr ...

  7. Zabbix unreachable poller processes more than 75% busy

    “Zabbix poller processes more than 75% busy”警报问题解决 虽然Zabbix的监控警报各种有,碰到最多的几个莫过于内存耗尽,网络不通,IO太慢还有这个“Zab ...

  8. 转:Java 异常结构体系

    原文地址:Java 异常结构体系 保存一份资料 前几天在参加网易和360公司的在线考试的时候,都出了一道关于java中异常类的多项选择题.这几天翻看了相关书籍和网上一些资料,结合自己的理解与思考,将自 ...

  9. LeetCode 821 Shortest Distance to a Character 解题报告

    题目要求 Given a string S and a character C, return an array of integers representing the shortest dista ...

  10. python之类中如何判断是函数还是方法

    通常我们认为在类中的函数为方法,类外面声明def为函数,这种说法有点片面 方法1: class Work(object): def show(self): print("执行show方法&q ...