python – Importing module not working

python – Importing module not working

Your directory structure let me think that you should try to import like this :

from first_page.ExcelToXML.main import excelToXml

because the ExcelToXML is under the first_page module, so it is viewed as a submodule of first_page.

Check this for details on what is file What is for?

The file should be present in every directory and sub directories whose classes should be made visible for import. In your case, the I am suspecting that the parent directory does not have the file. Add the file in the parent directory and import it as follows

import first_page.ExcelToXML

python – Importing module not working

Okay hello, the solution you found is (I think) a mess, you should read the official documentation about it
In short just add from .idea.main import excelToXml.
If it does not work, rename .idea folder to idea(without the dot) and add in your this line :from idea.main import excelToXml

Leave a Reply

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