对于py2exe,有​​没有办法选择可执行文件的保存位置?

时间:2015-06-02 14:36:39

标签: python-3.x py2exe

我知道已经有question这样的了,但是当我使用它时出现了这个错误:

Traceback (most recent call last):
File "C:/Users/rperera/PycharmProjects/PythonToExe/test.py", line 12, in <module>
save_path = filedialog.asksaveasfilename(defaultextension="*.exe", filetypes=("Executable File", "*.exe"))
File "C:\Python34\lib\tkinter\filedialog.py", line 380, in asksaveasfilename
return SaveAs(**options).show()
File "C:\Python34\lib\tkinter\commondialog.py", line 48, in show
s = w.tk.call(self.command, *w._options(self.options))
_tkinter.TclError: bad file type "*.exe", should be "typeName {extension ?extensions ...?} ?{macType ?macTypes ...?}?"

任何人都可以帮我解决这个问题吗?这是我的代码:

from distutils.core import setup
import py2exe, sys
import tkinter as tk
from tkinter import filedialog

input('Press Enter to continue and select your Python file you want to convert when the dialog shows up...')
tk.Tk().withdraw()
file_path = tk.filedialog.askopenfilename()

sys.argv.append("py2exe")
input("Press Enter to continue and choose where you want to save the new executable file when the dialog shows up...")
save_path = filedialog.asksaveasfilename(defaultextension="*.exe", filetypes=("Executable File", "*.exe"))
setup(console=[file_path], options={'py2exe': {'compressed': 1, 'bundle_files': 1, 'dist_dir': save_path + "dir"}})

0 个答案:

没有答案