title: import module from other folder python (errors)
body: <p>I am new to Python. I am using the following directory structure and am trying to import module OrgRepo into Func1. I am using a virtualenv and vs code as my IDE.</p>
  
  <p><code>
  src/
  ├── Functions
  │   ├── Func1
  │   └── Func2
  └── Shared
      ├── __init__.py
      ├── Repositories
      │   ├── __init__.py
      │   ├── OrgRepo
      └── Utilities
          ├── __init__.py
          └── DictUtil
  </code>
  I have also tried this without `<strong>init</strong>.py'</p>
  
  <p>This is my PATH:</p>
  
  <p><code>['/Users/username/Documents/Projects/myproject/name/src/Functions/Func1', '/Users/username/anaconda3/envs/my_virtual_env/lib/python37.zip', '/Users/username/anaconda3/envs/my_virtual_env/lib/python3.7', '/Users/username/anaconda3/envs/my_virtual_env/lib/python3.7/lib-dynload', '/Users/username/.local/lib/python3.7/site-packages', '/Users/username/anaconda3/envs/my_virtual_env/lib/python3.7/site-packages']
  </code></p>
  
  <p>I have tried the following in order to import OrgRepo into Func1:</p>
  
  <p>1: <code>from .Shared.Repositories import OrgRepo</code></p>
  
  <p><code>ModuleNotFoundError: No module named '__main__.Shared'; '__main__' is not a package</code></p>
  
  <p>2: <code>from ..Shared.Repositories import OrgRepo</code>
  '</p>
  
  <p><code>ValueError: attempted relative import beyond top-level package</code></p>
  
  <p>3: <code>from src.Shared.Repositories import OrgRepo</code></p>
  
  <p><code>ModuleNotFoundError: No module named 'src'</code></p>
  
  <p>4: `from Shared.Repositories import OrgRepo1</p>
  
  <p><code>'ModuleNotFoundError: No module named 'Shared'</code></p>
  
  <p>5: I am using VS Code and when I try to save the file:</p>
  
  <p>It automatically changes to this:
  <code>import OrgRepo
  import DictionaryUtilities
  import datetime
  import json
  import sys
  sys.path.insert(0, 'src/Repositories/')
  </code></p>
  
  <p>6:
  <code>import sys
  sys.path.insert(
      0, '/Users/username/Documents/Projects/project/m/src/Repositories')
  import OrgRepo</code></p>
  
  <p>and this: </p>
  
  <p><code>sys.path.insert(0, 'Repositories')</code>
  <code>sys.path.insert(0, .'Repositories')</code>
  <code>sys.path.insert(0, ..'Repositories')</code></p>
  
  <p>Upon running or saving, vs code changes it to this:
  <code>import OrgRepo
  import sys
  sys.path.insert(
      0, '/Users/username/Documents/Projects/project/m/src/Repositories')
  </code>
  and received this error:</p>
  
  <p><code>ModuleNotFoundError: No module named 'OrgRepo'</code></p>
  
  <p>I was able to install this with PIP and import it, but that does not suit our needs.</p>
  
  <p>I have read these posts:
  <a href="https://stackoverflow.com/questions/4383571/importing-files-from-different-folder">Importing files from different folder</a></p>
  
  <p><a href="https://stackoverflow.com/questions/20693687/python-import-modules-folder-structures">Python import modules, folder structures</a></p>
  
  <p><a href="https://stackoverflow.com/questions/43059505/how-to-import-multiple-python-modules-from-other-directories">How to Import Multiple Python Modules from Other Directories</a></p>
  
  <p><a href="https://stackoverflow.com/questions/22774433/how-to-properly-import-python-modules-from-an-adjacent-folder">How to properly import python modules from an adjacent folder?</a></p>
  
  <p>I tried to read/understand a few other posts as well . . . I even tried to bang on the Flux Capacitor a few times to no avail . . </p>
  
  <p>EDIT: I am using this code to upload as an AWS Lambda function. While the sys.path solution works locally it makes it does not fit into my workflow. This requires me to change the sys.path to import while uploading and causes problems with Intellisense. I would like to be able to be able to import the module directly. e.g. <code>import OrgRepo</code> so Intellisense does not throw errors and I can zip and upload my package to AWS. I have no problem uploading my package to AWS when I am able to import <code>&lt;module_name&gt;</code>.</p>
  
  <p>I activate my environment in Anaconda and then export the following PYTHONPATH environment variable:</p>
  
  <p><code>export PYTHONPATH=src/shared/repositories:src/shared/utilities</code></p>
  
  <p>I also tried <code>export PYTHONPATH=$PATH:src/shared/repositories:src/shared/utilities</code></p>
  
  <p>This worked for a period of time and now I am getting <code>PYTHON[unresolved-import]</code> with IntelliSense. I do not appear to get this error when I try to run the script from the directory above <code>/src</code>.</p>
  
  <p>I would be so grateful if somebody can show me how I can import my modules using the standard <code>import &lt;module&gt;</code> and have it consistently work.</p>