Fatal error detected: Module object for pyimod02_importers is NULL

7.4k Views Asked by At

After compiling the python script with auto-py-to-exe, I'm getting this error when I try to open the exe file. There's literally no information about this error on the internet, any ideas?

List of the modules I use in the script:

import secrets
import string
import tkinter as tk

import customtkinter
import pyperclip
3

There are 3 best solutions below

0
ALEX TORRES DURANGO On

I am going to explain how I solved this same error, I also used customtkinter, first you must locate yourself in the folder where you have your files and scripts, you are going to create a virtual environment, for this you go to the file explorer path and write cmd and das Before, the terminal opens in that path, or you simply right click on a space in the folder that you have open and click: "open terminal", in this terminal you will create the virtual environment and activate it like this step 1: pip install virtualenv step 2: virtualenv env step 3: cd env step 4: cd scripts step 5: activate.bat After activating it, we are going to check that we have all the necessary files, for this we check the path with the following command step 6: dir check that all your necessary files are there for your script to run then we are going to install pyinstaller like this step 7: pip install pyinstaller then we check that our libraries and necessary packages are installed in this virtual environment, for that we type the command: step 8: pip freeze customtkinter does not come by default, we must install it like this step 9: pip install customtkinter NOTE: if you have any other library or package external to Python, you must install it in the same way pip install (library name) then, with pip freeze, you check again that all the libraries are already added lastly, install and run auto-py-to-exe like so step 10: pip install auto-py-to-exe step 11: auto-py-to-exe

auto-py will open, the rest is simple add the .py file, choose "a directory", add "additional files", add the customtkinter path manually like so C:/Users/(USERNAME)/AppData/Local/Programs/Python/Python311/Lib/site-packages/customtkinter en USERNAME va tu usuario de la Windows then in the advanced options part, go to "--hidden-import" press + and then write csutomtkinter (this is to complement the path we entered earlier, since the customtkinter module, being relatively new, is under development and there are still errors) perfect now you click on generate .exe and ready you wait, you will know the rest, look for your file in the: carpeta ./dist/(nombre de tu carpeta)/(nombre de tu archivo)/.exe

3
Blake K On

The issue is python 3.11.4. Downgrade to 3.11.3 for now. Tested using two windows machines one running 3.11.4 and one 3.11.3.

0
mcardosoabreu On

I had the same problem. In my case, it was my auto-py-to-exe version.

I upgraded my auto-py-to-exe version, and this error was fixed:

pip install --upgrade auto-py-to-exe