I have a directory structure like:

In main.py, I try import classes.class1, and then in class1.py I try import class2.
When I run class1.py directly, it imports class2 successfully. However, when I try to run main.py instead, I get an exception that says ModuleNotFoundError: No module named 'class2'.
It seems like the main module cannot see class2. I can't understand the error. Shouldn't it be class1 that is importing class2, not main?
How can I fix the problem?
I thought that when a file was imported, it would see the file that would be in its directory, rather than having to rely on the .py file that calls the function from another directory.
I also tried the approach described in Importing a file that imports another file, but then I get an error that says ImportError: attempted relative import with no known parent package.