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

ModuleNotFoundError: No module named 'functions'

I have looked into other similar posts, but could not find an answer.

So,

Here is the structure of the project I am working on:

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

lyrics/__init__.py
lyrics/functions.py
manifold.py

When I execute manifold.py with this command:

./manifold.py

it calls:

import lyrics as lyr

which in turn calls init.py, which calls:

from lyrics import *
import functions

Here is the error that I get:

Traceback (most recent call last):
  File "./manifold.py", line 20, in <module>
    import lyrics as lyr
  File "/g../__init__.py", line 2, in <module>
    import functions
ModuleNotFoundError: No module named 'functions'

Any idea where the error comes from ?

Thanks

>Solution :

If you want to import relatively, you have to add the . before functions, i.e. from . import functions

The import there works similar to unix: The single dot is for the current directory. If you put two dots (..) you go up one level, three dots (...) goes up two levels and so on.

If you want to go absolute, then from lyrics import functions should work.

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