Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

No module named [filename] Python

I am trying to import Navigator class in renameFrame.py from navigator.py but, its giving me error ModuleNotFoundError: No module named ‘navigator’ In the below image you can see the directory structure.

enter image description here

Here is image of Navigator.py file

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

Thank you so much for your help 🙏🏻.

>Solution :

Python3 dropped support for implicit relative imports. You need to make the import absolute or explicitly relative by adding a leading .:

from .navigator import Navigator

Since you’re running rename.py, the Bunch File Rename directory will be in sys.path, but Bunch File Rename/packages is not. Due to this, navigator.py is not on any of the paths where python searches for packages.

Alternatively, you can do:

from packages.navigator import Navigator
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading