title: Project root folder path in Python
body: <p>I have a python project <code>$MY_PROJECT</code> where the python notebooks are in the folder <code>$MY_PROJECT/Analysis/src/notebooks</code>, and the python files are in <code>$MY_PROJECT/Analysis/src/notebooks/scripts</code>.</p>
  <p>Inside each notebook, I have these instructions to load the python files that are in the scripts folder. Later, I import the method in the notebook, like it is shown below.</p>
  <pre><code>module_path = os.path.abspath(os.path.join('./scripts'))
  if module_path not in sys.path:
      sys.path.append(module_path)
  
  from scripts.parser import load_static_data
  </code></pre>
  <p>Inside the <code>scripts</code> folder, there is a file (<code>parser.py</code>) with the <code>__main__</code> method. I decided in this file to not append the scripts module to the <code>sys.path</code> because the file is already located in the <code>scripts</code> folder.</p>
  <p>If I try to run the <code>parser.py</code> in the command line, I get the error below.</p>
  <pre><code>python scripts/parser.py input1 ./output-folder
  Traceback (most recent call last):
    File &quot;scripts/parser.py&quot;, line 10, in &lt;module&gt;
      from scripts.data_loading import load_static_data
  ModuleNotFoundError: No module named 'scripts'
  </code></pre>
  <p>How can I define that every time I run a python file or a notebook, the classes are loaded from the project root folder (i.e., <code>$MY_PROJECT</code>)?</p>