Skip to content Skip to sidebar Skip to footer

Py2exe Openpyxl Importerror

I have a python application that depends on openpyxl and works well when running it through the python interpreter. However, when creating an exe with py2exe. The exe was generated

Solution 1:

The issue is because __version__ is read from .constants.json file and it is not being taken up by py2exe. For work around, I edited the library file openpyxl\packaging\extended.py

#from openpyxl import __version____version__ = "2.4.5"

I commented the import and created a variable __version__ with the version text from .constants.json file present in openpyxl library. Again created the executable using py2exe.

Worked fine for me.

Solution 2:

I was having the same problem using openpyxl 2.4.3 . 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'

Solution 3:

I had the same problem.

First, I tried the proposed solution of downgrading to 2.3, but I use read-only functions that didn't work.

Then, reading some openpyxl forums I found that the problem is that 2.4 uses a Jason file for the configuration. But I couldn't instruct py2exe to include it and use it.

Finally, I used pyInstaller, and it worked at the first try.

Solution 4:

In openpyxl\packaging\extended.py add it at line 5:

__version__ = str(__version__)

Post a Comment for "Py2exe Openpyxl Importerror"