小编典典

通过pandas导入时,openpyxl模块不具有属性“ __version__”

python

我从奔跑的熊猫回溯到:
site-packages\pandas\io\excel.py line 58, in get_writer AttributeError: 'module' object has no attribute '__version__'

我在PyInstaller存储库https://github.com/pyinstaller/pyinstaller/issues/1890中找到了与git问题相关的链接,
并找到了我的openpyxl版本,将其手动添加到get_writer方法中,如下所示:

def get_writer(engine_name):
    if engine_name == 'openpyxl':
        try:
            import openpyxl
            #remove when conda update available
            openpyxl.__version__ = '2.3.2'
            # with version-less openpyxl engine
            # make sure we make the intelligent choice for the user
            if LooseVersion(openpyxl.__version__) < '2.0.0':
                return _writers['openpyxl1']
            elif LooseVersion(openpyxl.__version__) < '2.2.0':
                return _writers['openpyxl20']
            else:
                return _writers['openpyxl22']
        except ImportError:
            # fall through to normal exception handling below
            pass

    try:
        return _writers[engine_name]
    except KeyError:
        raise ValueError("No Excel writer '%s'" % engine_name)

仍然没有骰子。错误回溯中给出的行号甚至都不会改变。然后,我将openpyxl版本更新为2.3.5,仍然收到错误。openpyxl 初始化
文件中包含一个 版本 变量:

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

有任何已知或潜在的修复程序或解决方法吗?


阅读 541

收藏
2021-01-20

共1个答案

小编典典

编辑不会产生影响,因为该过程已编译为这些模块运行所通过的exe。将我需要的部分导出到anaconda环境之外,现在该过程可以顺利进行了。

2021-01-20