我使用Tkinter(在python v2和v3上测试)创建了一个简单的python gui应用程序,并尝试使用py2app和py2exe来分发它。
我需要以下库:
try... except ImportError:...
获取正确的内容)我写了3个模块:
我的setup.py目前使用来自this tutorial的帮助:
'''
py2app/py2exe build script for NVConnectApp.
Will automatically ensure that all build prerequisites are available
via ez_setup
Usage (Mac OS X):
python setup.py py2app
Usage (Windows):
python setup.py py2exe
'''
import ez_setup
ez_setup.use_setuptools()
import sys
from setuptools import setup
mainscript = 'NVConnectApp.py'
if sys.platform == 'darwin':
extra_options = dict(
setup_requires=['py2app'],
app = [mainscript],
# Cross-platform applications generally expect sys.argv to
# be used for opening files.
options=dict(py2app=dict(argv_emulation=True)),
# Packages
packages=['boto3'],
# Modules
py_modules = ['DroneLogbookServer', 'NVServer']
)
elif sys.platform == 'win32':
extra_options = dict(
setup_requires=['py2exe'],
app=[mainscript],
# Packages
packages=['boto3'],
# Modules
py_modules = ['DroneLogbookServer', 'NVServer']
)
else:
extra_options = dict(
# Normally unix-like platforms will use "setup.py install"
# and install the main script as such
scripts=[mainscript],
)
setup(
name="NVConnectApp",
**extra_options
)
OSX(python 2.7.8):
在为OSX打开py2app的.app时遇到错误。该错误与Boto3's configparser that's been solved here有关。当我从原始脚本运行程序时,不会发生错误。
Windows(python 3.4.3):
运行python setup py2exe
时出现error: invalid command 'py2exe'
错误。一个小小的研究说,因为我没有在Setup.py中导入py2exe,但在导入之后(导入设置后)我得到以下内容:
3 missing Modules
------------------
? readline imported from cmd, code, pdb
? win32api imported from platform
? win32con imported from platform
Building shared code archive 'dist\library.zip'.
并且没有生成.exe。
我的Setup.py有什么问题?