- #1
- 2,168
- 193
I have a project folder called Projects and inside that folder I have a file called my_functions.py. Now I have a folder named Project 1
and inside there is another python file called test.pySo it is something like
-Projects-
my_functions.py
-Project 1-
test.py
Now I have some functions in the my_functions.py file such as f1, f2 etc.
Now, I need to take a function from my_functions.py and use it inside the test.py
I have used things like
from my_functions import f1
from .my_functions import f1
from Projects.my_functions import f1
For the first one I get an error called
ModuleNotFoundError: No module named 'my_functions'
I have searched online and I find that I need to do something about _init_.py somewhere (?) The problem is, I am new in codding so I could not find where to put that module, in what way etc. So if someone can tell me what to do step by step it would be really helpful.
Thanks Thanks
and inside there is another python file called test.pySo it is something like
-Projects-
my_functions.py
-Project 1-
test.py
Now I have some functions in the my_functions.py file such as f1, f2 etc.
Now, I need to take a function from my_functions.py and use it inside the test.py
I have used things like
from my_functions import f1
from .my_functions import f1
from Projects.my_functions import f1
For the first one I get an error called
ModuleNotFoundError: No module named 'my_functions'
I have searched online and I find that I need to do something about _init_.py somewhere (?) The problem is, I am new in codding so I could not find where to put that module, in what way etc. So if someone can tell me what to do step by step it would be really helpful.
Thanks Thanks