Import Module error when using cx_Freeze (PYTHON)

727 views Asked by At

I have spent the last 2 hours searching the web to find very little and nothing that helps.

Hoping someone here will be able to help me.

When using cx_Freeze to convert my .py file to a .exe files, I get an error stating no module named xlsxwriter can be found. When this module is removed from the packages list the program compiles with no problem.

My code:

import cx_Freeze

Executables = [cx_Freeze.Executable("test.py")]


cx_Freeze.setup(
    name="Sort PLL Bale Lists",
    options={"build_exe": {"packages":['xlrd','xlsxwriter']}},

    executables = Executables

    )
1

There are 1 answers

2
cutteeth On

Try adding includes list to your code eg: includes = [xlrd,xlsxwriter]. Refer to this SO post for help. If the error persists try installing xlrdwriter with pip install xlsxwriter.

There is a chance that you have xlrd already installed and you have not installed xlsxwriter. This can be verified with pip freeze. pip freeze will provide a list of installed packages.