
seen from United States
seen from United Kingdom
seen from Philippines
seen from China

seen from United States

seen from Sweden
seen from China
seen from China

seen from Singapore
seen from Sweden
seen from Peru
seen from United States
seen from China

seen from Vietnam

seen from United Kingdom
seen from China

seen from Ukraine

seen from Malaysia
seen from China
seen from Poland
How to: py2exe - generate single executable file
How to: py2exe – generate single executable file
py2exe – generate single executable file
I thought I heard that py2exe was able to do this, but I never figured it out. Has anyone successfully done this? Can I see your setup.py file, and what command line options you used?
Basically I’m thinking of it giving me a single executable file that does something like unzips itself to maybe /temp and runs.
Answer: py2exe – generate single executable…
View On WordPress
使用py2exe遇到的问题总结
最近用python+pyqt+pywin32做了一个catia的二次开发,虽然在我自己的机器上用源代码运行时没有任何问题,但是在用py2exe将代码打包成exe文件时却出现了不少问题,经过不断的google和测试,这些问题终于一一得到解决,先将问题及其解决办法总结如下:
1.出现应用程序配置错误
在之前的一篇介绍py2exe的文章中曾经提到过这个问题及其解决办法>>>猛击这里< <<。这个问题出现的原因在于python2.6是用vc2008编译的,因此用py2exe转换后需要安装vc2008的运行库才能运行,而公司的电脑上都没有安装VC2008的运行库,因此要运行我的程序还要在每台机器上再安装个东西是不可接受的,看来只有用python2.5了。
2.运行打包后的程序提示“ImportError: No module named sip” 解决办法:打包时通过"-p"参数手动加上sip模块,即运行python setup.py py2exe -p sip,或者在setup.py文件中加上参数:20
1 option = {"py2exe": 2 {"includes":["sip"], 3 #其他选项。。。 4 } 5 } 6 setup(options = option, 7 #其他参数 8 ) 9
3.程序中的需要的资源文件打包后找不到
解决办法1:将程序需要的资源文件使用列在qrc文件中,使用pyqt提供的资源打包工具pyrcc4将资源文件打包成py格式。比如,程序中需要用到logo.png,logo.png在images目录下,那么image.qrc文件如下格式:
1 < !DOCTYPE RCC><rcc version="1.0"> 2 <qresource> 3 <file>images/logo</file> 4 5 </qresource> 6 </rcc>
接着运行pyrcc4进行打包 pyrcc4 image.qrc > qrc_image.py 然后在程序中import qrc_image后就可以直接使用了,比如QIcon(":/images/logo.png") 需要注意的是,如果你的图片是其他格式,比如gif,ico,jpeg,tiff等,打包后程序是无法直接显示这些图片的,还需要将pyqt4\plugins\下的imageformats目录拷贝到打包后的dist目录下,imageformats目录下的几个文件qgif4.dll,qico4.dll,qjpeg4.dll,qmng4.dll,qsvg4.dll,qtiff4.dll分别对应了显示gif,ico,jpeg等格式图片所需要的动态链接库文件,可以根据自己具体要显示的图片格式选择是否复制。 解决办法2:使用setup()中的data_files参数,data_files是一个列表,每一个元素都是一个二维元组,格式为(目标文件夹,[源文件列表]),实例如下
1 files = [ 2 ("images",["images/p1.png","images/p2.png"]), 3 ("icons",["icon/logo.ico"]), 4 ] 5 setup(data_files = files, 6 #其他参数 7 )
4.获取程序所在目录
由于py2exe打包后__file__属性失效,因此无法再通过这种方法获取程序所在的目录,解决办法:猛击这里,说的很详细,我就不翻译了,懒人直接使用Alternate Solution提供的代码就行了。
py2exe打包程序报错
py2exe是Python下的一个插件,从名字就可以看出,它是一个用于将python代码转成window下的exe可执行程序的工具,这样在没有安装python的机器上也可以运行python程序。可是最近在将我遍写的一些python脚本部署到其他机器上时无法运行,而这些脚本在我的机器上可以正常运行,错误如下:
后来在py2exe的教程中找到这样一句话,安装了其中所说的补丁后果然解决了:
If the program works on your computer, but not on the user's computer, they may have to install the Microsoft Visual C++ 2008 redistributable package, which can be found on Microsoft's website. This typically occurs when the user does not have python installed.
大意就是如果程序在你的机器上能够运行,但在其他机器上--尤其是没有安装python的机器--不能运行,你需要安装Microsoft Visual C++ 2008 redistributable package。 Microsoft Visual C++ 2008 redistributable package下载地址:X86版,X64版
py2exe打包PyQt4图片解码插件
用py2exe打包PyQt4时,得到exe程序打开jpg等压缩格式的图片,主要是因为没有将解码的插件一起打包。
解决办法是复制site-packages\PyQt4\plugins\imageformats中相应的解码dll到dist目录plugins\imageformats下,然后在dist目录下新建一个文件qt.conf,内容为:
[Paths] Prefix = . Binaries = .
这样便解决了不能打开压缩图片的问题。
So I've been trying to package up a litle demo of my game to play as a standalone exe/app. I've not even got the the exe yet, becayse apparently aI have the wrong type of python!
Runnin on someone else's computer, py2app gives this error:
ImportError: No module named os
OS being a pretty basic python momdule. Turns out, py2app has just symlinked python in there so of course it doesn't work on anyone else's computers...
So now I'm trying to find a Framework python (instead of package or something). I think the installer on python.org is it? I'll find out shortly.