I have the following project structure :
-project
-src
-package1
-script1.py
-__init__.py
-package2
-script2.py
- __init__.py
-__init__.py
Now script1.py
includes two functions :
def my funct1():
print("Hello")
def my funct2():
// do something
Now I want to run funct1()
in script2.py
. I am new to something like that as I always write my whole code in main.py
and that's it.
I have searched for this problem and I wrote the following code in script2.py
:
from src.package1.script1 import *
funct1()
This gives me the following error :
from src.package1.script1 import *
ModuleNotFoundError: No module named 'src'
Somebody please help me to import the function. I have another question, when I solve the import error, do I directly call funct1()
in script2.py
or do I need to do something extra, like including a main function in script2.py
??