title: Python ModuleNotFoundError when importing a package
body: <p>I getting and error when I try to import a package from another folder. I have the folowing:</p>
  <pre><code>project  
  |  
  |-- main.py  
  |  
  |-- lib  
  |   |-- __init__.py
  |   |-- main_class.py
  |   |-- global_functions.py
  |   |-- cg_api_simple
  |   |-- cg_api_status
  |  
  |-- tests    
      |-- __init__.py  
      |-- test_main_class.py  
  </code></pre>
  <p>Where my <code>lib/__init__.py</code> has:</p>
  <pre><code>from lib.main_class import PyGecko
  </code></pre>
  <p>and my <code>test/__init__.py</code> is empty.</p>
  <p>When I run <code>python3 -m unittest test_main_class.py</code> I get:</p>
  <pre><code>======================================================================
  ERROR: test_main_class (unittest.loader._FailedTest)
  ----------------------------------------------------------------------
  ImportError: Failed to import test module: test_main_class
  Traceback (most recent call last):
    File &quot;/usr/lib/python3.8/unittest/loader.py&quot;, line 154, in loadTestsFromName
      module = __import__(module_name)
    File &quot;/home/someone/Documents/pythoncoingecko/tests/test_main_class.py&quot;, line 1, in &lt;module&gt;
      from lib import PyGecko
  ModuleNotFoundError: No module named 'lib'
  
  
  ----------------------------------------------------------------------
  Ran 1 test in 0.000s
  
  FAILED (errors=1)
  </code></pre>
  <p>I've already tried:</p>
  <ul>
  <li>Add /project and /project/lib to my PYTHONPATH</li>
  <li>Use sys before import</li>
  <li>Add .. before the import</li>
  <li>Try to remove <code>__init__.py</code> from both folders</li>
  </ul>
  <p>The only time I don't get an error is when I move <code>test_main_class.py</code> to where main.py is located. How could I solve this?
  You can see more on github</p>
  <blockquote>
  <p><a href="https://github.com/SrJMaia/pythoncoingecko" rel="nofollow noreferrer">https://github.com/SrJMaia/pythoncoingecko</a></p>
  </blockquote>
  <p>Thanks</p>