py2exe 可以用来将python program 以exe的形式发布。

安装py2exe

对于python 3.x

pip install py2exe 可以直接安装

对于python 2.7, 需要下载exe安装,

https://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/

这里详细记录一下python2.7下 py2exe的安装注意的问题

1. 安装时出现如下错误,

Python version 2.7 required, which was not found in the registry

解决:

copy下面的脚本,创建一个registry.py, 然后运行python registry.py

import sys

from _winreg import *

# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
installpath, installpath, installpath
) def RegisterPy():
try:
reg = OpenKey(HKEY_CURRENT_USER, regpath)
except EnvironmentError as e:
try:
reg = CreateKey(HKEY_CURRENT_USER, regpath)
SetValue(reg, installkey, REG_SZ, installpath)
SetValue(reg, pythonkey, REG_SZ, pythonpath)
CloseKey(reg)
except:
print "*** Unable to register!"
return
print "--- Python", version, "is now registered!"
return
if (QueryValue(reg, installkey) == installpath and
QueryValue(reg, pythonkey) == pythonpath):
CloseKey(reg)
print "=== Python", version, "is already registered!"
return
CloseKey(reg)
print "*** Unable to register!"
print "*** You probably have another Python installation!" if __name__ == "__main__":
RegisterPy()
  1. 错误



    import py2exe_util

    ImportError: DLL load failed: %1 is not a valid Win32 application.



    解决: 这是安装错了py2exe的版本。 下载列表中的win64, amd64似乎不是指OS的版本。我PC是win64,但是安装win64版本有上述错误。安装py2exe-0.6.9.win32-py2.7.exe后解决了问题。

生成exe

按照http://www.py2exe.org/index.cgi/Tutorial#Step1中的guide 不再详述。

注意的问题:

如果生成的exe遇到local module 找不到的情况,

解决方案: 在所有subfolder中加上空白的 __init__.py

Reference

http://www.py2exe.org/

http://www.py2exe.org/index.cgi/Tutorial#Step1

Release Python Program as exe的更多相关文章

  1. python脚本生成exe可执行文件

    1.先安装第三方插件: py2exe. Get py2exe from http://www.py2exe.org/ 在download里下载与自己python对应的版本 2.写一个测试python文 ...

  2. Python 获得程序 exe 的版本号

    Python 获得程序 exe 的版本号 python中需要安装 pywin32 包 # based on http://stackoverflow.com/questions/580924/pyth ...

  3. 没有 RunInstallerAttribute.Yes 的公共安装程序。在 C:/Program/xx.exe 程序集中可能可以找到

    今天在装服务的时候,装了半天总是提示 没有 RunInstallerAttribute.Yes 的公共安装程序.在 C:/Program/xx.exe 程序集中可能可以找到“Yes”属性. 才发现同事 ...

  4. 打包python脚本为exe可执行文件-pyinstaller和cx_freeze示例

    本文介绍使用cx_freeze和pyinstaller打包python脚本为exe文件 cx_freeze的使用实例 需要使用到的文件wxapp.py, read_file.py, setup.py ...

  5. python打包成exe

    目前有三种方法可以实现python打包成exe,分别为 py2exe Pyinstaller cx_Freeze 其中没有一个是完美的 1.py2exe的话不支持egg类型的python库 2.Pyi ...

  6. PhpStorm中报 “Cannot run program git.exe, 系统找不到指定的文件” 

    http://blog.csdn.net/lamp_yang_3533/article/details/52003021 在使用PhpStorm的GitHub或Git功能时,经常会出现以下错误信息: ...

  7. 打包python脚本为exe的坎坷经历, by pyinstaller方法

    打包python脚本为exe的坎坷经历, by pyinstaller方法 又应验了那句歌词. 不经历风雨, 怎么见得了彩虹. 安装过程略去不提, 仅提示: pip install pyinstall ...

  8. 关于python打包成exe的一点经验之谈

    我经常用python写些脚本什么的,有时候脚本写完以后,每次运行都得在IDE打开在运行,很麻烦,所以经常将python编译成exe.SO...有了一点经验,在这和大家分享一下.      python ...

  9. Cannot run program “git.exe”: createprocess error=2,系统找不到指定的文件

    Android Studio提供VCS(Version Control System)版本控制系统,默认情况使用Git.GitHub工具需要配置git.exe路径,否则提示“cannot run pr ...

随机推荐

  1. bzoj4145 [AMPPZ2014]The Prices(状压dp)

    Description 你要购买m种物品各一件,一共有n家商店,你到第i家商店的路费为d[i],在第i家商店购买第j种物品的费用为c[i][j], 求最小总费用. Input 第一行包含两个正整数n, ...

  2. NSA互联网公开情报收集指南:迷宫中的秘密·上

    猫宁!!! 参考链接: https://www.nsa.gov/news-features/declassified-documents/assets/files/Untangling-the-Web ...

  3. elasticsearch映射 mapping

    mapping的格式个应用,主要是创建索引(数据库)的时候指明type 的field类型,然后elasticsearch可以自动解析

  4. jQuery中$.getJSON

    $.getJSON $.getJSON()是专门为ajax获取json数据而设置的,并且支持跨域调用,其语法的格式为: $.getJSON( url, //请求URL [data], //传参,可选参 ...

  5. mysql文件系统

    1 磁盘划分 在一台mysql服务器上,一般是sda做系统,sdb做数据,sdc做日志. 2 磁盘调度策略 linux默认调度策略是cfq,mysql上一般改为deadline echo 'deadl ...

  6. Codeforces Round #418 (Div. 2) A

    Description A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight ...

  7. freertos之特点

    主要特点:协程(co-routine):任务间的中断通信机制              支持可抢占式/协作式任务调度 .FreeRTOS-MPU              内核对象可以动态或静态分配 ...

  8. Suricata的初始化脚本

    见官网 https://suricata.readthedocs.io/en/latest/initscripts.html

  9. spark block读写流程分析

    之前分析了spark任务提交以及计算的流程,本文将分析在计算过程中数据的读写过程.我们知道:spark抽象出了RDD,在物理上RDD通常由多个Partition组成,一个partition对应一个bl ...

  10. border 0px和border none的区别

    border:0px这个表示的是边框为0像素,表示边框的像素 border:none 这个表示无边框(边框的绘制方式),边框的绘制方式有很多种:solid dashed等等