Different people would suggest different solutions as there are multiple ways to solve this problem.
Method 1
Add the path of the subdirectory from you want to run the script in sys.path. In fact you can add as many paths as you can to let compiler find the script from the given locations.
Method 2
You can write a separate python file called setup.py and call it in your main script. This file should work as follows:
Say your file structure looks like
app/
__init__.py
mymodule.py
inner_folder/
myscript.py
setup.py
Your setup.py should look somewhat like this
from setuptools import setup
setup(
name='my-app',
version='0.1',
packages=['app'],
install_requires=[
# a list of required packages if needed
],
)
Original Source : Why does my python not add current working directory to the path?