我在使用 gui2exe 创建可执行文件时遇到问题
我决定尝试使用 gui2exe 来制作可执行文件,但无论使用 PyInstaller、Py2exe 还是 cxFreeze,我都无法让它工作。它创建一个非启动可执行文件(我运行它,它开始加载,然后停止加载,什么也没有,任务管理器在进程中没有它)。
当 gui2exe 让我测试已编译的项目并且我点击“是”时,我收到以下错误:“该项目从未被编译或它的可执行文件已被删除。”
当我通过批处理文件或 cmd 进行编译时,不会发生类似的情况。
请提供有关使用 gui2exe 的任何帮助、指南、手册、文档!
- 我在 Windows 7 32 位
- Python 2.7
- GUI2exe-0.5.1
- 上运行它我安装了 pyinstaller-1.5.1、py2exe-0.6.9、cx_freeze-4.2.3
更新: 这是我正在使用的测试代码: 文件 Tk_tester.py (这是主要的)
# -*- coding: mbcs -*-
from Tkinter import *
import ttk
from ScrolledWidgets import ScrolledText
root = Tk()
root.title('Gui2exe tester application')
txt = ScrolledText(root)
txt.pack(side='top', fill='both', expand=1)
txt.Text['font'] = ('Tahoma', 10)
b = ttk.Button(root, text='Quit', command=root.quit)
b.pack(side='bottom', anchor='e')
root.mainloop()
和文件 ScrolledWidgets.py
# -*- coding: mbcs -*-
from Tkinter import *
import ttk
class ScrolledText(ttk.Frame):
def __init__(self, master, scrolls = 'v'):
ttk.Frame.__init__(self, master)
self['relief'] = 'sunken'
self['borderwidth'] = 1
self.rowconfigure(0, weight = 1)
self.columnconfigure(0, weight = 1)
self.__scroll = scrolls
self.Text = Text(self, relief = 'flat', borderwidth = 0)
self.Text.grid(column = 0, row = 0, sticky = 'news')
if self.__scroll == 'v':
yscroll = ttk.Scrollbar(self, orient = 'vertical')
yscroll.grid(column = 1, row = 0, sticky = 'ns')
self.Text['yscrollcommand'] = yscroll.set
yscroll['command'] = self.Text.yview
elif self.__scroll == 'h':
xscroll = ttk.Scrollbar(self, orient = 'horizontal')
xscroll.grid(column = 0, row = 1, sticky = 'ew')
self.Text['xscrollcommand'] = xscroll.set
xscroll['command'] = self.Text.xview
elif self.__scroll == 'both':
yscroll = ttk.Scrollbar(self, orient = 'vertical')
yscroll.grid(column = 1, row = 0, sticky = 'ns')
self.Text['yscrollcommand'] = yscroll.set
yscroll['command'] = self.Text.yview
xscroll = ttk.Scrollbar(self, orient = 'horizontal')
xscroll.grid(column = 0, row = 1, sticky = 'ew')
self.Text['xscrollcommand'] = xscroll.set
xscroll['command'] = self.Text.xview
这可以编译正常。但是当我运行生成的 exe 时,我收到“ImportError:没有名为 carchive 的模块”。
我尝试过仅使用控制台的应用程序 - 它运行正常。
I decided to try gui2exe for making my executables, but I cannot get it to work, with neither PyInstaller, Py2exe or cxFreeze. It creates a non-starting executable (I run it, it starts loading, then it stops loading and nothing, task manager doesn't have it in the processes).
When gui2exe offers me to test the compiled project and I hit "Yes" I get the following error: "This project has never been compiled or it's executable has been deleted."
Nothing like that happens when I compile via a batch file or cmd.
Any help, guides, manuals, docs on using gui2exe, please!
- I'm running it on Windows 7 32bit
- Python 2.7
- GUI2exe-0.5.1
- I have pyinstaller-1.5.1, py2exe-0.6.9, cx_freeze-4.2.3 installed
UPDATE:
Here's the test code that i'm using:
file Tk_tester.py (that is main one)
# -*- coding: mbcs -*-
from Tkinter import *
import ttk
from ScrolledWidgets import ScrolledText
root = Tk()
root.title('Gui2exe tester application')
txt = ScrolledText(root)
txt.pack(side='top', fill='both', expand=1)
txt.Text['font'] = ('Tahoma', 10)
b = ttk.Button(root, text='Quit', command=root.quit)
b.pack(side='bottom', anchor='e')
root.mainloop()
and the file ScrolledWidgets.py
# -*- coding: mbcs -*-
from Tkinter import *
import ttk
class ScrolledText(ttk.Frame):
def __init__(self, master, scrolls = 'v'):
ttk.Frame.__init__(self, master)
self['relief'] = 'sunken'
self['borderwidth'] = 1
self.rowconfigure(0, weight = 1)
self.columnconfigure(0, weight = 1)
self.__scroll = scrolls
self.Text = Text(self, relief = 'flat', borderwidth = 0)
self.Text.grid(column = 0, row = 0, sticky = 'news')
if self.__scroll == 'v':
yscroll = ttk.Scrollbar(self, orient = 'vertical')
yscroll.grid(column = 1, row = 0, sticky = 'ns')
self.Text['yscrollcommand'] = yscroll.set
yscroll['command'] = self.Text.yview
elif self.__scroll == 'h':
xscroll = ttk.Scrollbar(self, orient = 'horizontal')
xscroll.grid(column = 0, row = 1, sticky = 'ew')
self.Text['xscrollcommand'] = xscroll.set
xscroll['command'] = self.Text.xview
elif self.__scroll == 'both':
yscroll = ttk.Scrollbar(self, orient = 'vertical')
yscroll.grid(column = 1, row = 0, sticky = 'ns')
self.Text['yscrollcommand'] = yscroll.set
yscroll['command'] = self.Text.yview
xscroll = ttk.Scrollbar(self, orient = 'horizontal')
xscroll.grid(column = 0, row = 1, sticky = 'ew')
self.Text['xscrollcommand'] = xscroll.set
xscroll['command'] = self.Text.xview
This compiles ok. But when i run the resulting exe i get an "ImportError: No module named carchive".
I've tried with an only-console app - it runs OK.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有同样的问题。一个简单的修复方法是在运行 pyinstaller 之前手动将存档路径添加到 PYTHONPATH 中。
carchive.py
应该位于 pyinstaller 文件夹中的某个位置。对我来说,它位于 svn.pyinstaller.org\PyInstaller\loader 下I had the same issue. An easy fix is to manually add the path for carchive to your PYTHONPATH before running pyinstaller.
carchive.py
should be somewhere in your pyinstaller folder. For me it was undersvn.pyinstaller.org\PyInstaller\loader
py2exe 努力寻找所有依赖的模块,但有时会失败,例如 prgram 动态构建模块路径并使用 __import__ 来加载它。
在这种情况下,您必须修改
setup.py
并手动添加缺少的模块。以下代码修复了“没有名为 _qt 的模块”:py2exe tries hard to find all depending modules, but sometimes it fails, eg a prgram builds an module path dynamically and uses
__import__
to load it.In this case you have to modify your
setup.py
and add missing modules manually. The following code fixes an "no module named _qt":