Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用py2exe创建python可执行文件_Python_Py2exe - Fatal编程技术网

使用py2exe创建python可执行文件

使用py2exe创建python可执行文件,python,py2exe,Python,Py2exe,我试图创建文件NewExistGUI2.py的可执行文件,其中GUI是使用wxpython制作的。该文件依赖于另外两个文件localsettings.py和Tryone.py。我参考了py2exe文档,创建了一个setup.py文件,如下所示: from distutils.core import setup import py2exe setup(name = 'python eulexistdb module', version = '1.0',

我试图创建文件NewExistGUI2.py的可执行文件,其中GUI是使用wxpython制作的。该文件依赖于另外两个文件localsettings.pyTryone.py。我参考了py2exe文档,创建了一个setup.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']
        )
并在命令行中使用

python setup.py py2exe

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

我建议您创建一个具有以下结构的模块(ExistGUI):

ExistGUI
\_ __init__.py
|_ localsettings.py
|_ Tryone.py
bin
\_ NewExistGUI2.py
您的init.py应该具有:

from . import localsettings, Tryone

__version__ = 1.0
您的setup.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 setup.py py2exe。确保在setup.py中包含模块的任何要求。另外,删除先前生成的dist目录,以确保安全


希望这有帮助。

python setup.py py2exe的输出是什么?它应该告诉您缺少什么,或者为什么没有为您创建exe。请尝试将:scripts=['NewExistGUI2.py',]添加到setup.py。输出没有显示任何错误消息。它显示了编译python文件的字节,并且没有任何错误。如何告诉setup.py NewExistGUI2.py是主文件,localsettings.py、Tryone.py是附件文件。添加脚本=['NewExistGUI2.py']也不起作用。还尝试将所有文件添加到脚本中,但失败。那么,我如何使用PyInstaller创建程序的EXE呢。??