安装pyinstaller包

pip3 install pyinstaller

如果不行

pip3 install pyinstaller -i https://pypi.doubanio.com/simple

准备一个你要打包的.py文件,cd到该文件路径下,打开cmd

在命令行中输入:

pyinstaller -F xxx.py

或者

pyinstaller.exe -F xxx.py

都是可以的

运行之后会多出两个文件夹,dist和build,打包好的文件在dist文件夹内

已经生成exe文件,直接点击运行,结果如下

xxx.py

# coding=utf-
import turtle
import time turtle.pensize()
turtle.pencolor("yellow")
turtle.fillcolor("red") turtle.begin_fill()
for _ in range():
turtle.forward()
turtle.right()
turtle.end_fill()
time.sleep() turtle.penup()
turtle.goto(-, -)
turtle.color("violet")
turtle.write("Done", font=('Arial', , 'normal')) turtle.mainloop()

我这里用到-F,生成单个可执行文件。

一些常用参数:

-D, --onedir    Create a one-folder bundle containing an executable (default)

-F, --onefile  Create a one-file bundled executable.

  -n NAME, --name NAME   Name to assign to the bundled app and spec file (default: first script’s basename)
  -p DIR, --paths DIR    A path to search for imports (like using PYTHONPATH). Multiple paths are allowed, separated by ‘:’, or use this option multiple times
  -w, --windowed, --noconsole

将python项目.py文件打包成.exe文件的更多相关文章

  1. 将 Python3 文件打包成 exe 文件

    我们用 Python 写好的代码,如何给别人在没有配置 Python 环境的情况下直接使用呢?尤其是面向 windows 众. 因为 Python 是一门解释性的语言,离开了 Python 解释器,P ...

  2. python画猫并打包成EXE文件

    因python自带有海龟画图库,尝试给爱猫的小仙女来画个猫咪. 1.代码如下 from turtle import * #两个函数用于画心 def curvemove(): for i in rang ...

  3. [Python]项目打包:5步将py文件打包成exe文件 简介

    1.下载pyinstaller并解压(可以去官网下载最新版): http://nchc.dl.sourceforge.net/project/pyinstaller/2.0/pyinstaller-2 ...

  4. [Python]项目打包:5步将py文件打包成exe文件(转)

    1.下载pyinstaller并解压(可以去官网下载最新版): http://nchc.dl.sourceforge.net/project/pyinstaller/2.0/pyinstaller-2 ...

  5. 将py文件打包成exe文件

    PyInstaller工具是跨平台的,它既可以在 Windows平台上使用,也可以在 Mac OS X 平台上运行.在不同的平台上使用 PyInstaller 工具的方法是一样的,它们支持的选项也是一 ...

  6. Pycharm下将py文件打包成exe文件

    1. 在PyCharm下安装PyInstaller 1. 首先,打开自己要发布的工程   2. 点击底部的[Terminal]打开终端,中输入命令pip install pyinstaller后回车, ...

  7. python程序开子进程打包成exe文件运行炸内存原因剖析

    首先给出伪代码 from multiprocessing import Process def task(): print("hahaha") pass if __name__ = ...

  8. Python 之pyinstaller模块打包成exe文件

    一.安装pyinstaller pip install pyinstaller 二.下载安装pyinstaler运行时所需要的windows扩展pywin32 https://github.com/m ...

  9. Python文件打包成EXE文件

    工具:pyinstaller 安装:pip install pyinstaller 使用: 1 将依赖文件集中到一个文件夹:           pyinstaller -D -w xxx.py    ...

随机推荐

  1. Zuul的高级使用

    原文链接:https://blog.csdn.net/u011820505/article/details/79373594

  2. 常用HTTP状态码总结

    HTTP状态码(HTTP Status Code) 1xx(临时响应) 表示临时响应并需要请求者继续执行操作的状态代码. 代码 说明 (继续) 请求者应当继续提出请求. 服务器返回此代码表示已收到请求 ...

  3. snap应用多版本卸载

    Ubuntu18.04新增了几个内置软件使用Snap格式.同样的沙箱式处理方式,除了Canonical主推的Snap,还有Fedora的Flatpak和AppImage.一般正常使用没问题,就是第一次 ...

  4. 【mybatis】mybatis一条sql更新两张数据表,mybatis关联更新多张数据表

    示例sql: <update id="receipt" parameterType="com.pisen.cloud.luna.ms.security.code.b ...

  5. 微信开放平台apk的应用签名的获取

    https://open.weixin.qq.com 微信里面的应用签名相关的签名信息 1.首先生成JKS文件,放入的是包名,利用的是android studio工具生成的. 步骤:随便建立一个安卓项 ...

  6. jdk8 接口的变化

    在jdk8之前,interface之中可以定义变量和方法,变量必须是public.static.final的,方法必须是public.abstract的.由于这些修饰符都是默认的以下写法等价 publ ...

  7. 彻底搞懂B树、B+树、B*树、R 树

    出处:http://blog.csdn.net/v_JULY_v . 第一节.B树.B+树.B*树1.前言: 动态查找树主要有:二叉查找树(Binary Search Tree),平衡二叉查找树(Ba ...

  8. 消息队列mq总结

    一.消息队列概述消息队列中间件是分布式系统中重要的组件,主要解决应用解耦,异步消息,流量削锋等问题,实现高性能,高可用,可伸缩和最终一致性架构.目前使用较多的消息队列有ActiveMQ,RabbitM ...

  9. Spring Boot 使用 JWT 进行身份和权限验证

    上周写了一个 适合初学者入门 Spring Security With JWT 的 Demo,这篇文章主要是对代码中涉及到的比较重要的知识点的说明. 适合初学者入门 Spring Security W ...

  10. 一问带你区分清楚Authentication,Authorization以及Cookie、Session、Token

    上周写了一个 适合初学者入门 Spring Security With JWT 的 Demo .Demo 地址:https://github.com/Snailclimb/spring-securit ...