title: Jenkins ImportError module not found
body: <p>I have a file structure like this:</p>
  <pre><code>Main/
  |----unit_tests
  |    |---test_main.py
  |    |---__init__.py
  |--main.py
  |--__init__.py
  |--requirements.txt
  </code></pre>
  <p>test_main.py:</p>
  <pre><code>import unittest.mock
  from main import MainFunction
  from nose.tools import assert_is_not_none, assert_is_none, assert_equal
  
  class TestMainLogic(unittest.case):
  ~~~ code here ~~~~
  </code></pre>
  <p>When running my unit tests in test_main.py from Pycharm, all is well. However when I try to run it in a Jenkins setup, I get:</p>
  <pre><code>+ python3 unit_tests/test_main.py
  Traceback (most recent call last):
    File &quot;unit_tests/test_main.py&quot;, line 4, in &lt;module&gt;
      from main import MainFunction
  ModuleNotFoundError: No module named 'main'
  </code></pre>
  <p>Here's my Jenkinsfile:</p>
  <pre><code>pipeline 
  {
      environment 
      {
          PATH = &quot;/home/jenkins/.local/bin:$PATH&quot;
      }
      stages 
      {
          stage('build') 
          {
              steps
              {
                  sh 'python3 --version'
                  sh 'wget https://bootstrap.pypa.io/get-pip.py'
                  sh 'python3 get-pip.py'  
                  sh 'pip3 install -r requirements.txt'
                  echo 'build phase has finished'
              }
          }
          stage('Lint')
          {
              steps
              {
                  sh 'pylint unit_tests/test_main.py'
              }
          }
          stage('test')
          {
              steps
              {
                  sh 'python3 unit_tests/test_main.py'
              }
              post
              {
                  always
                  {
                      cleanWs()
                  }
              }
          }
      }
  }
  </code></pre>
  <p>I've followed several posts and I'm just not getting an answer that works. I tried:<a href="https://stackoverflow.com/questions/28532467/python-module-import-failure-in-jenkins">Python module import failure in Jenkins</a> and its linked answers. I do not have access to ssh into the Jenkins server and find the path so I need a way to set it at execution.</p>