openpyxl module does not have attribute '__version__' when imported by pandas

天涯浪子 提交于 2019-11-29 15:10:11

Edits were not making an impact because the process was compiled into an exe that these modules were running through. Exported the sections I needed outside of my anaconda environment and now the process works without a hitch.

I will add my workaround to this discussion as I was having the same problem using openpyxl 2.4.0 and maybe a few others are stuck too. I found that to create a .exe file you have to revert to an older version of openpyxl. To do so:

  1. Open the command prompt and uninstall openpyxl with 'pip uninstall openpyxl'
  2. Reinstall openpyxl using an older version 'pip install openpyxl==2.3.5'

Now you should be able to create your .exe file using py2exe, cx_freeze, etc.

This is my fix: go to your openpyxl site-package folder (for me it's: C:\Python27\Lib\site-packages\openpyxl). Copy all variables in your .constant.json file directly into the _ init _.py file, so it looks like:

import json
import os
__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"
try:
    here = os.path.abspath(os.path.dirname(__file__))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!