检查root目录下的__init__.py. openpyxl从.constrants.json文件中读取这些信息.然而,PyInstaller无论如何都无法做到正确.我会自己写一个__version__.py文件,并在__init__.py中替换它们.
另一种更简单的方法是像这样更改__init__.py:
import json
import os
# Modified to make it work in PyInstaller
#try:
# here = os.path.abspath(os.path.dirname(__file__))
# src_file = os.path.join(here, ".constants.json")
# with open(src_file) as src:
# constants = json.load(src)
# __author__ = constants['__author__']
# __author_email__ = constants["__author_email__"]
# __license__ = constants["__license__"]
# __maintainer_email__ = constants["__maintainer_email__"]
# __url__ = constants["__url__"]
# __version__ = constants["__version__"]
#except IOError:
# # packaged
# pass
__author__ = 'See AUTHORS'
__author_email__ = 'eric.gazoni@gmail.com'
__license__ = 'MIT/Expat'
__maintainer_email__ = 'openpyxl-users@googlegroups.com'
__url__ = 'http://openpyxl.readthedocs.org'
__version__ = '2.4.0-a1'
"""Imports for the openpyxl package."""
from openpyxl.compat.numbers import NUMPY, PANDAS
from openpyxl.xml import LXML
from openpyxl.workbook import Workbook
from openpyxl.reader.excel import load_workbook
print('You are using embedded openpyxl... 2.4.0-a1 ...')