title: Python venv ModuleNotFoundError
body: <p>(Before marking me with duplicate question votes, please note that everything that I can find on this question has to do with virtualenv, not venv)</p>
  
  <p><strong>System</strong>:</p>
  
  <ul>
  <li>Ubuntu Server 16.04</li>
  <li>Python 3.6 installed, Python 3.5 native</li>
  </ul>
  
  <p><strong>Background</strong>
  (Contrived example, so might have a typo or two, but the idea is the important part)</p>
  
  <p>I have a project in the form of:</p>
  
  <pre><code>Project/
  ├── __init__.py
  └── project
      ├── packageA
      │   ├── fileA.py
      │   └── __init__.py
      └── packageB
          ├── fileB.py
          └── __init__.py
  </code></pre>
  
  <p>in fileb.py, I have an import statement such as</p>
  
  <pre><code>import project.packageA.fileA
  </code></pre>
  
  <p>I create a venv by; </p>
  
  <pre><code>cd /path/to/Project; python3.6 -m venv .venv; source .venv/bin/activate
  </code></pre>
  
  <p>then I run</p>
  
  <pre><code>source project/packageB/fileB.py
  </code></pre>
  
  <p>This will give me an error: </p>
  
  <pre><code>ModuleNotFoundError: no module named 'project'
  </code></pre>
  
  <p><strong>Attempts to address</strong>: </p>
  
  <ol>
  <li>Add the path to "Project" and "project" to $PATH</li>
  <li>Modify $PYTHONPATH in the .venv/bin/activate script so that sys.path now points to "Project" and "project"</li>
  <li>Completely read the docs <a href="https://docs.python.org/3/tutorial/venv.html" rel="nofollow noreferrer">here</a></li>
  <li>Verified that os.sys.path shows Project and project paths</li>
  </ol>
  
  <p><strong>Question</strong>: It must be possible to do module imports using venv or it would be of zero value -- so what am I fundamentally missing in my setup? (With viritualenv, I just used 'add2virtualenv')</p>
  
  <p>[<strong>Edit</strong> - Showing more detail]</p>
  
  <pre><code># Changes to .venv/bin/activate
  PYTHONPATH="/home/steve/Temp/Project:/home/steve/Temp/Project/project:$PYTHONPATH"
  export PYTHONPATH
  
  python -c "import os; print(os.sys.path)"
  ['', '/home/steve/Temp/Project', '/home/steve/Temp/Project/project', .....
  </code></pre>
  
  <p>[<strong>Edit2</strong> - adding packageA to PYTHONPATH Works]</p>
  
  <p>If I add 'path/to/packageA' to my PYTHONPATH, the import works. To use this, I would have to add each subpackage to my project -- less than ideal for large projects.</p>