我用 tkinter 在 python 中制作了一个简单的 GUI 程序,并尝试使用 py2exe 将其转换为 .exe。但是,我遇到了一个问题。当我尝试运行 exe 时,它会非常快速地闪烁错误然后消失。所以我能做的最好的事情就是对错误进行屏幕截图。
我该如何解决这个问题?

编辑
迅猛龙,这是我的安装文件。它几乎是最基本的。我将如何将init.tcl集成到代码中?
from distutils.core import setup
import py2exe
setup(console=[r'C:\Python26\Random Password Generator.py'])
Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个应用程序,它使用py2exe从一些使用matplotlib的Python代码创建一个exe文件.除了我的可执行文件很大之外,它工作得很好.在它下面运行转换脚本会创建43.5 MB的包(exe及其依赖项).我知道可能有一些事情可以减少我的应用程序的大小.
减少应用程序大小的任何提示?
我的转换脚本:
from distutils.core import setup
import py2exe
import matplotlib
setup(
windows=[{'script': r'ElectronOrbitalGenerator.py'}],
data_files=matplotlib.get_py2exe_datafiles(),
options={r'py2exe':{r'includes': r'ElementConfig',
r'includes': r'ColorConv',
r'includes': r'Tkinter',
r'includes': r're',
r'includes': r'math',
r'includes': r'sys',
r'includes': r'matplotlib',
r'includes': r'mpl_toolkits',
r'dll_excludes': [r'MSVCP90.dll'],
}},
)
Run Code Online (Sandbox Code Playgroud)
这些是我的程序需要运行的所有模块:
import ElementConfig, ColorConv
import Tkinter, re, math, sys
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
Run Code Online (Sandbox Code Playgroud) 我制作了一个带有pygame代码的MP3播放器:
from Tkinter import *
import pygame
import glob
import tkFont
songs=[]
for x in glob.glob('C:\WhaleTunes\Downloaded/*mp3'):
songs.append(x)
Admin=Tk()
num=0
plpa=-1
songas=Label(Admin,text='',bg='red')
songas.place(relx=0.0,rely=0.7)
def play(number):
pygame.mixer.music.unpause()
pygame.mixer.music.load(songs[number])
pygame.mixer.music.play()
songas.configure(text=songs[number])
def pause():
pygame.mixer.music.pause()
def Pre():
global num
if num == 0:
z = len(songs)
num=z
num+=1
num-=1
play(num)
def Next():
global num
num+=1
play(num)
#init pygame mixer
pygame.mixer.init()
#atach all buttons & labels
fons=tkFont.Font(family="bold", size=40)
fon=tkFont.Font(family="Helvetica", size=20)
tit=Label(Admin,text='Mp3 Player',font=fons,fg='grey',bg='red')
tit.place(relx=0.2,rely=0.0)
playnpause=Button(Admin,text='Play',command=lambda:play(num),fg='yellow',bg='red',font=fon)
playnpause.place(relx=0.0,rely=0.4)
last=Button(Admin,text='Previous',command=Pre,fg='yellow',bg='red',font=fon)
last.place(relx=0.2,rely=0.4)
first=Button(Admin,text='Next',command=Next,fg='yellow',bg='red',font=fon)
first.place(relx=0.5,rely=0.4)
pauses=Button(Admin,text='Pause',command=pause,fg='yellow',bg='red',font=fon)
pauses.place(relx=0.7,rely=0.4)
Admin.minsize(width=500, height=200)
Admin.maxsize(width=500, height=200) …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个可以将工件部署到 Artifactory 的 python 脚本。我正在使用 Python 3.4,我希望生成的脚本将其通过 py2exe,因此外部库可能会产生问题。
通过我所有的研究,我发现一种方法是这样的,但我不知道如何将它“翻译”为Python:
curl -X PUT -u user:password --data-binary @/absolute/path/my-utils-2.3.jar "http://localhost/artifactory/my-repo/my/utils/2.3/"
Run Code Online (Sandbox Code Playgroud)
我怎样才能在Python中实现这一点?或者有任何一种部署方式吗?
我有一个基于 concurrent.futures 的非常简单的脚本,它在命令行(Python 2.7)中运行良好,但是在使用 py2exe 或 Pyinstaller 编译时崩溃(编译后的程序会打开越来越多的进程,如果我不这样做,最终会完全阻塞窗口)先杀了他们)。
代码非常标准/简单,所以我很难理解这个问题的起源......有没有人更早经历过这个?(我发现与多处理的类似问题相关的讨论......但没有什么可以用来解决我的问题)
# -*- coding: utf8 -*-
import os
import socket
import concurrent.futures
def simple_checkDomain(aDomain):
print aDomain
# Do other stuff
def main():
with concurrent.futures.ProcessPoolExecutor(max_workers=4) as executor:
for domain in ["google.com","yahoo.com"]:
job = executor.submit(simple_checkDomain, domain)
if __name__ == "__main__":
main()
Run Code Online (Sandbox Code Playgroud)
最好的问候,S
python py2exe pyinstaller multiprocessing concurrent.futures
我正在使用py2exe转换使用numpy并获得一个非常大的结果文件夹的脚本,并且似乎很多大文件来自numpy我不使用的包的部分,例如numpy.linalg.
为了减少创建的文件夹的大小,我被认为应该在numpy没有英特尔MKL/BLAS/ATLAS/LAPACK的情况下进行编译.
我该怎么做这个改变?
EDIT
在C:\Python27\Lib\site-packages\numpy\linalg我发现了以下文件:_umath_linalg.pyd(34MB)和lapack_lite.pyd(18MB),使用时,其被复制到分配的文件夹py2exe.如果可能的话,我想在仍然能够使用numpy数组的同时消除对这些的依赖.包含的另一个大文件位于C:\Python27\Lib\site-packages\numpy\core并被称为_dotblas.pyd(12MB).是否有可能删除它?
我正在尝试在 py2exe 中编译一个 python 程序。它返回一堆丢失的模块,当我运行可执行文件时,它说:“MKL 致命错误:无法加载 mkl_intel_thread.dll”
我所有的“非绘图”脚本都可以完美运行,只是使用“matplotlib”和“pyqtgraph”的脚本不起作用。
我什至在 Numpy/Core/mkl_intel_thread.dll 中找到了该文件,并将其放入带有 .exe 的文件夹中,但它仍然不起作用。有谁知道如何解决这个问题?
我使用的是 Anaconda Python 3.4 和 matplotlib 1.5.1
我在Python中使用QtDesigner构建了一个小GUI应用程序,我将应用程序传递给团队中使用Autodesk 360 + Autocad的几个人.
我的应用程序使用QFileDialog命令来获取文件名,这是众所周知的是一个bug时,安装在计算机上的Autodesk 360:链接1,链接2.
错误:调用文件对话框时,控制台始终返回以下错误:
log4cplus:ERROR No appenders could be found for logger (AdSyncNamespace).
log4cplus:ERROR Please initialize the log4cplus system properly.
Run Code Online (Sandbox Code Playgroud)
错误并不重要,因为它不会更改处理,但我不希望任何错误消息像这样弹出.
考虑到我们经常会将应用程序分发给每天使用Autodesk产品的人,并且该bug看起来不会很快得到纠正,是否可以忽略此错误,以便它不会显示在控制台中?也许在构建过程中忽略了一些东西py2exe......我不知道在哪里搜索.谢谢 !
我对编程很陌生。我最近使用 python 和 pygame 制作了一个简单的贪吃蛇游戏。当然,我可以通过运行 .py 脚本轻松玩我的游戏,但为了与我不太懂计算机的朋友分享它,我继续尝试找出如何将我的代码编译成单个 .exe 来制作它对他们来说很容易。
我尝试过 py2exe 和 cx_Freeze,两者都为我提供了一个包含 .exe 和其他几个文件(依赖项)的 dist 或 build 目录。这确实有效,因为我可以压缩整个文件夹并通过 .zip 分发,但这并不理想。我希望能够将所有内容打包在一个文件中。
所以我开始谷歌搜索“如何将 python 编译成单个 exe”。然而,与我之前尝试过谷歌搜索的许多编程问题不同,我只是无法得到直接、可靠的答案。到目前为止,我尝试过的最新可靠答案给了我这个 setup.py 脚本:
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1, 'compressed': True}},
windows = ['snek.py'],
zipfile = None
)
# Python 3.4.4, py2exe 0.9.2.2; modules used: pygame, random
Run Code Online (Sandbox Code Playgroud)
尽管如此,它还是给了我一个完整的文件夹,而不是一个 .exe,没有它程序就无法运行。
所以,我带着两个问题来找你,这位无所不知、伟大的 stackoverflow。
以防万一我错过了什么:你建议我如何实现我的单一 .exe 梦想?
还有:这到底为什么这么难?
我有一个Python应用程序,可以从网站获取多语言信息,并在一个小的GUI窗口(基于wxpython)中显示它们.
我(目前)不在我的源文件中使用任何特定的unicode语句.
现在,当我从Eclipse中运行我的python应用程序时,很好地显示了法语字符(比如ë),当我从py2exe打包版本运行它时,该字符变得不稳定.我真的不明白为什么使用py2exe构建不会产生unicode或编码相关的错误.
但是,要解决这个问题,并按照该文章中,我包裹着我的琴弦unicode(my_string, "utf-8")电话只是其输出到屏幕前.这解决了它.
问题:
unicode()在显示好方法之前,是否在调用中包装字符串?我试过围绕unicode多次缠绕我的脑袋,但似乎我不兼容unicode: - |
py2exe ×10
python ×10
matplotlib ×2
pygame ×2
tkinter ×2
artifact ×1
artifactory ×1
autodesk ×1
blas ×1
c++ ×1
compilation ×1
deployment ×1
lapack ×1
log4cplus ×1
numpy ×1
optimization ×1
pyinstaller ×1
python-3.x ×1
tcl ×1
unicode ×1