我试图使用cx_freeze和py2exe将用python 3编写的程序转换为.exe。但转换并运行程序后,我收到以下错误:
Traceback (most recent call last):
File "astroConverter.py", line 8, in <module>
File "C:\Users\Konrad\PycharmProjects\astroConverter\mainwindow.py", line 2, in <module>
from widgets.widgets import MainMenu, Toolbar, TextField
File "C:\Users\Konrad\PycharmProjects\astroConverter\widgets\widgets.py", line 1, in <module>
from widgets.menus import FileMenu, EditMenu, HelpMenu
File "C:\Users\Konrad\PycharmProjects\astroConverter\widgets\menus.py", line 2, in <module>
from common import Info
File "C:\Users\Konrad\PycharmProjects\astroConverter\common.py", line 2, in <module>
from astropy.io import fits
File "C:\Python34\lib\site-packages\astropy\__init__.py", line 73, in <module>
_check_numpy()
File "C:\Python34\lib\site-packages\astropy\__init__.py", line 61, in _check_numpy
from .utils import minversion
File "C:\Python34\lib\site-packages\astropy\utils\__init__.py", line 15, in <module>
from .codegen import *
File "C:\Python34\lib\site-packages\astropy\utils\codegen.py", line 15, in <module>
from .introspection import find_current_module
File "C:\Python34\lib\site-packages\astropy\utils\introspection.py", line 14, in <module>
from ..extern import six
File "C:\Python34\lib\site-packages\astropy\extern\six.py", line 60, in <module>
_import_six()
File "C:\Python34\lib\site-packages\astropy\extern\six.py", line 57, in _import_six
"distribution.".format(_SIX_MIN_VERSION))
ImportError: Astropy requires the 'six' module of minimum version 1.7.3; normally this is bundled wi
th the astropy package so if you get this warning consult the packager of your Astropy distribution.
这是我的cx_freeze setup.py脚本:
import sys
from cx_Freeze import setup, Executable
buildExeOptions = {"packages": ["astropy", "numpy", "matplotlib"],
"includes": ["six"],
"silent": ["-s"]}
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
setup(name='astroConverter',
version="0.4",
description="Format converter used in astronomy",
options={"build_exe": buildExeOptions},
executables=[Executable("astroConverter.py", base=base)]
)
和py2exe脚本:
from distutils.core import setup
import py2exe
setup(console=['astroConverter.py'])
以下是pip freeze
的输出:
C:\WINDOWS\system32>pip freeze
astropy==1.0.1
cx-Freeze==4.3.4
matplotlib==1.4.3
numpy==1.9.2
py2exe==0.9.2.2
pyparsing==2.0.3
python-dateutil==2.4.1
pytz==2015.2
six==1.9.0
UNKNOWN==0.0.0
virtualenv==13.1.0
如您所见,我的six
模块的版本比astropy要求的版本新。
奇怪的是,我已经正确安装了所有软件包,并且在运行python astroConverter.py
时一切正常。这是GUI应用程序(它使用tkinter)。有谁知道我怎么能强制cx_freeze或py2exe正确包括&#34;六&#34;模块?