【发布时间】:2017-01-19 21:02:48
【问题描述】:
我正在尝试从 python 文件创建一个可以在 Windows 上运行的可执行文件。我正在使用 Mac 并尝试使用 cx_Freeze 执行此操作。我有一个文件夹,里面有 2 个文件:pyTest.py 和 setup.py。这是pyTest.py的内容:
import numpy as np
print(np.sqrt(2))
这里是 setup.py 的内容:
import sys
from cx_Freeze import setup, Executable
build_exe_options = {"packages": ['numpy'],
"excludes": ['Tkinter', 'tcl', 'ttk']}
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(name='test1',
version='0.1',
description='test',
options = { "build_exe" : build_exe_options},
executables = [Executable('pyTest.py', base=base)])
当我运行终端python setup.py build 时,会创建一个名为“build”的文件夹,其中仅包含另一个名为“exe.macosx-10.6-intel-2.7”的文件夹,其中包含一个名为“lib”的文件夹 libncursesw.5, pyTest,Python。 pyTest 和 Python 都是 Unix 可执行文件。我正在使用第二台装有 Windows 10 的计算机,我试图用它来运行我试图制作的 .exe 文件。我尝试运行 pyTest 文件,但它不起作用。
【问题讨论】:
标签: python windows macos cx-freeze