关于python程序打包的介绍就不多说了,大部分的python基础书上都有介绍。这里就直接演练。

只是一个简单的demo,一个demo项目中,有一个hello文件,文件中有一个函数hello,函数的作用是读取testdd.txt文件中的数据然后输出。

这是小编准备的python视频教程+PDF学习资料,想要的加群:496248129即可获取!

这个项目中还有其他的一些东西,以演示打包。

整个项目结构如下:

"-webkit-tap-highlight-color: transparent; box-sizing: border-box; font-family: Consolas, Menlo, Courier, monospace; font-size: 16px; white-space: pre-wrap; position: relative; line-height: 1.5; color: rgb(153, 153, 153); margin: 1em 0px; padding: 12px 10px; background: rgb(244, 245, 246); border: 1px solid rgb(232, 232, 232); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"

>singledemodemomodelinit.pyentity.pystatictest.txthello.pyMANIFEST.insetup.pyhello.py中的代码:

"-webkit-tap-highlight-color: transparent; box-sizing: border-box; font-family: Consolas, Menlo, Courier, monospace; font-size: 16px; white-space: pre-wrap; position: relative; line-height: 1.5; color: rgb(153, 153, 153); margin: 1em 0px; padding: 12px 10px; background: rgb(244, 245, 246); border: 1px solid rgb(232, 232, 232); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"

>def hello():f = open('testdd.txt', 'r')content = f.read()f.close()print contentsetup.py中的代码如下:

"-webkit-tap-highlight-color: transparent; box-sizing: border-box; font-family: Consolas, Menlo, Courier, monospace; font-size: 16px; white-space: pre-wrap; position: relative; line-height: 1.5; color: rgb(153, 153, 153); margin: 1em 0px; padding: 12px 10px; background: rgb(244, 245, 246); border: 1px solid rgb(232, 232, 232); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"

>coding:utf-8''''''import osimport sysfrom setuptools import setup, find_packagessetup(name = "demo",version = "0.0.1",packages = find_packages(),include_package_data = True,entry_points = {'console_scripts' : ['demo = demo.hello:hello'],},package_data = {'demo':['*.txt']},author = "the5fire",author_email = '嘻嘻嘻嘻嘻嘻嘻@email.com',url = "http://www.the5fire.com",description = 'a demo for setuptools',)还有一个文件需要注意,MANIFEST.in:

"-webkit-tap-highlight-color: transparent; box-sizing: border-box; font-family: Consolas, Menlo, Courier, monospace; font-size: 16px; white-space: pre-wrap; position: relative; line-height: 1.5; color: rgb(153, 153, 153); margin: 1em 0px; padding: 12px 10px; background: rgb(244, 245, 246); border: 1px solid rgb(232, 232, 232); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"

>recursive-include demo *.txt

虽然只有一句话,但是是要通过它来包括你要打包的非py文件。

打包时候的命令有两个,

一个是打包成egg文件:python setup.py bdist_egg 。执行完成后,会在同目录下多了两个文件夹:demo.egg-info和dist,egg文件就在dist中,这个文件可以上传到pypi.python.com上,供大家下载。或者上传到某网盘,通过pip install --no--index find-links=[url]来下载。

另外一种是打包成压缩文件形式:python setup.py sdist 。执行结果同上,不过文件格式不同。

打包完成之后,当然要安装了,上一篇介绍了virtualenv,创建一个虚拟环境以供测试。然后执行python setup.py install 就会在你的虚拟环境的bin下创建一个demo的可执行文件,你在虚拟环境中运行:demo,输出结果。

很简单的东西,但是需要参考。

python关闭exe程序_Python打包exe程序一行简单的代码为什么就是那么多人不知道?...相关推荐

  1. python绿色版运行程序_Python打包exe运行程序,分享你的技术成果!

    本文转载于公众号:你想要

  2. python封装成可执行的小程序_Python打包小程序

    简单说明: 在待打包文件的文件夹[shift+右键]打开命令行窗口,输入 pyinstaller -F xxx.py 即可. 打包后的exe文件出现在 dist 文件夹中. 详细说明: cmd 进入到 ...

  3. 用Tkinter打造自己的Python IDE开发工具(1)建立一个简单的代码编辑器

    用Tkinter打造自己的Python IDE开发工具(1)建立一个简单的代码编辑器 很多Python初学者,安装完Python后,已经包含了IDLE代码开发和调试系统.都会再安装各种Python开发 ...

  4. 好用的python打包软件_Python打包exe文件方法汇总【4种】

    title: Python打包exe文件方法 copyright: true top: 0 date: 2018-08-11 21:08:21 tags: 打包 categories: Python进 ...

  5. windows开机运行python脚本_python打包exe开机自动启动的实例(windows)

    一.背景 简单的写个.exe程序,没必要去学习mfc.c++等,可以学习python.python可以轻易的调用windows的api,轻松的实现你想干的事.下面就是实现打包的exe文件开机自动运行. ...

  6. python封装方法有几种_Python打包exe文件方法汇总【4种】

    Python 打包 exe 文件方法汇总 Python 作为解释型语言,发布即公开源码, 虽然是提倡开源但是有些时候就是忍不住想打包成 exe ,不仅仅是为了对代码进 行加密,而是为了跨平台.防止有些 ...

  7. python网易云音乐下载打包exe文件,Windows可运行

    下载原理: 通过官方的下载链接http://music.163.com/song/media/outer/url?id=歌曲id.mp3, 分析网页寻找歌曲id组装成song_url,urlretri ...

  8. python教程程序_Python如何发布程序的详细教程

    如何发布一个Python程序: 1.安装一个pyInstaller 在pycharm里点 file -–>setting-–>Project workspace-->Interpre ...

  9. python failed to execute_PyQt5 Pyinstaller 打包 exe 提示 failed to execute script

    系统环境为:win7 32 位虚拟机 python 3.5.2 pyinstaller 3.3.1 PyQt5.9 python 文件在未打包时可运行 但是-w 打包后提示: failed to ex ...

  10. python判断火车票座位_Python抢票程序优化,可以选择车次和座次

    Python抢票程序优化,可以选择车次和座次 阅读文本大概需要 5 分钟. pk 哥在元旦前写了一篇关于自动化抢票的程序 用Python抢火车票加邮件通知,同时建了一个火车票助力群,本来只是写着玩玩, ...

最新文章

  1. Android --- RecyclerViwe中使用SnapHelper报错:“An instance of OnFlingListener already set.”
  2. Android中Webview使用javascript调用事先定义好的Java函数
  3. mongo基础---增删改查
  4. 代理 XP”组件已作为此服务器安全配置的一部分被关闭。系统管理员可以使用 sp_configure 来启用“代理 XP”。...
  5. Tomcat 总体结构
  6. rem 之js代码获取font-size值(适合移动手机端)
  7. python如何批量下载邮箱全部附件_Python编写执行测试用例及定时自动发送最新测试报告邮件...
  8. Merry Christmas and Happy New Year~
  9. linux 重启21端口命令,修改SSH默认远程端口为21号端口
  10. 解决zipfile压缩的文件路径太深,直接调用即可
  11. 秒懂!何凯明的深度残差网络PPT是这样的|ICML2016 tutorial
  12. win10系统 专业版 安装教程
  13. python微信投票该用户被锁定、恢复时间_微信登录多久恢复正常
  14. wordpress启动_使用Wumblr在WordPress中启动微博
  15. python判断闰年和平年
  16. 读书笔记-真实的诸葛亮-2
  17. 零基础转行新媒体运营,有哪些必须要掌握的技能
  18. NX程序调试方法实例讲解
  19. 史上最牛mysql-06 (多表连接)
  20. 如何使用时间机器进行备份?最全的Time Machine时间机器备份教程

热门文章

  1. Web of science(WOS)引文跟踪
  2. Atitit 常见软件设计图纸总结 目录 1.1. ui原型图与html 2 1.2. 业务逻辑 伪代码 各种uml图 2 1.3. 总体设计图纸 结构图 层次图 架构图 2 1.4. 业务逻辑
  3. Atitit 综合原则 软件与项目开发中的理念信念 目录 1.1. 建议组合使用扬长避短 1 1.2. 常见数据库 mysql oracle mssql mongodb postgre sqlit
  4. Atitit 流水线子线程异常处理 1.1. 大概原理是 FutureTask排除异常 FutureTask.get can throw ExecutionException,can catc
  5. Atitit 提取sfit特征点,并绘制到原图上
  6. main.cpp first defined here 解决
  7. Julia Rust : 看递归上的运行效率PK
  8. 您有一封阿里云自动化运维沙龙邀请函待查收
  9. 陈绪:3月21日阿里云北京峰会专场出品人
  10. 【图像分割】基于matlab遗传算法优化K聚类图像分割【含Matlab源码 1605期】