使用py2ex创建python可执行文件

2024-09-25 18:17:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图创建文件NewExistGUI2.py的可执行文件,其中GUI是使用wxpython生成的。该文件依赖于其他两个文件本地设置.pyTryone.py公司。我参考了py2exe文档,并创建了一个设置.py文件格式:

from distutils.core import setup    
import py2exe

    setup(name = 'python eulexistdb module',
        version = '1.0',
        description = 'Python eXistdb communicator using eulexistdb module',
        author = 'Sarvagya Pant',
        py_modules = ['NewExistGUI2','localsettings','Tryone']
        )

并在命令行中使用

^{pr2}$

但我没有在dist文件夹中创建主程序NewExistGUI2.py的任何.exe文件。我现在该怎么办?在


Tags: 文件from文档pyimport可执行文件setupwxpython
1条回答
网友
1楼 · 发布于 2024-09-25 18:17:20

我建议您使用以下结构创建一个模块(ExistGUI):

ExistGUI
\_ __init__.py
|_ localsettings.py
|_ Tryone.py
bin
\_ NewExistGUI2.py

您的初始化.py应具有:

^{pr2}$

你的设置.py应该看起来像:

from setuptools import setup, find_packages
import ExistGUI
import py2exe

setup(
     name = 'ExistGUI',
     version = ExistGUI.__version__,
     console=['bin/NewExistGUI2.py'],
     description = 'Python eXistdb communicator using eulexistdb module',
     author = 'Sarvagya Pant',
     packages= find_packages(),
     scripts=['NewExistGUI2.py',],
     py_modules = ['localsettings','Tryone'],
     include_package_data=True,
     zip_safe=False,
)

然后运行python设置.pypy2exe。请确保在中包含对模块的任何要求设置.py. 另外,删除先前生成的dist目录,只是为了确定。在

希望这有帮助。在

相关问题 更多 >