码迷,mamicode.com
首页 > 其他好文 > 详细

用py2exe打包pyqt4出现的问题(转)

时间:2014-10-11 15:50:45      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   io   使用   ar   for   sp   

使用pyqt完成窗体界面很方便,但是打包成exe之后会有问题,在网上找到解决办法如下:

Another Solution to the same problem:

1 from distutils.core import setup
2 import py2exe
3 setup(windows=[{"script":"main.py"}], options={"py2exe":{"includes":["sip"]}})

 

I found that on the web, unfortunately don‘t know anymore where, but it also works for me!

Obviously is the second part only a way to get the " --includes sip" parameter directly into the script, but the use of "windows" instead of "console" doesn‘t open a console window, but immediately a Qt window in my case.

 

Fix for PyQt4

If you get the following error:

ImportError: No module named _qt

The solution is to add PyQt4._qt to the setup function (see bellow). I found the solution for the problem here.

1 from distutils.core import setup
2 import py2exe
3 
4 setup(windows=[{"script" : "app.pyw"}], options={"py2exe" : {"includes" : ["sip","PyQt4._qt"]}})

 

或者我们直接在源代码中加入:
import sip  #程序打包需要
import  decimal #程序打包需要

也是可以的。


用py2exe打包pyqt4出现的问题(转)

标签:des   style   blog   color   io   使用   ar   for   sp   

原文地址:http://www.cnblogs.com/chuanheng/p/py2exe_error.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!