我试了下cx_Freeze去打包python3.4,打包成功后,然后我双击运行,貌似就直接退出了。
代码很简单,只是尝试下
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from Ui_fasd import Ui_Form
class mytest(QWidget, Ui_Form):
def __init__(self, parent = None):
"""
Constructor
"""
QWidget.__init__(self, parent)
self.setupUi(self)
@pyqtSlot()
def on_pushButton_clicked(self):
print('clicked')
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Form = QtGui.QWidget()
ui = mytest()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
在控制台下 我运行程序 提示下面的错误
D:\fasd>D:\fasd\main.exe
Traceback (most recent call last):
File "D:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27
, in <module>
exec(code, m.__dict__)
File "E:\project\testPack\main.py", line 2, in <module>
from PyQt4.QtGui import *
File "C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2214, in _find_a
nd_load
File "C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2189, in _find_a
nd_load_unlocked
File "C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line 321, in _call_wi
th_frames_removed
File "C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2214, in _find_a
nd_load
File "C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2203, in _find_a
nd_load_unlocked
File "C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_u
nlocked
File "C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_b
ackward_compatible
AttributeError: 'module' object has no attribute '_fix_up_module'
这是什么问题呢?
4 个解决方案
#1
额module 就是找不到了 唉
#2
是不是用的虚拟的python环境,看看环境变量。
#3
环境变量有配置 ,同样的代码在python2.7竟然可以生成exe 纠结
#1
额module 就是找不到了 唉
#2
是不是用的虚拟的python环境,看看环境变量。
#3
环境变量有配置 ,同样的代码在python2.7竟然可以生成exe 纠结
#4
具体原因参考这个
网页链接