Python ImportError: No module named …

Symptom:

from MY_FOLDER.MY_FILE import MY_CLASS causes an error:
ImportError: No module named MY_FOLDER.MY_FILE

Debugging:

  1. Execute the program in debug mode,
  2. In the Variables window expand Special Variables,
  3. Read the __warningregistry__ value.

Possible cause:

The __init__.py file is missing in the directory of the referenced class.

Solution:

Create an empty __init__.py file in the directory where the class is referenced from.

Leave a comment

Your email address will not be published. Required fields are marked *