title: Import Another File Error
body: <p>My folder/file structrue is:</p>
  
  <pre><code>testpkg/test/__init__.py;
  testpkg/test/test1.py
  testpkg/test/test2.py
  testpkg/setup.py
  </code></pre>
  
  <p><code>testpkg/test/__init__.py</code> file is empty.<br>
  <code>testpkg/test/test1.py</code> file content:</p>
  
  <pre><code>class Test1:
      def __init__(self, name):
          self.name = name
  
      def what_is_your_name(self):
          print(f'My name is {self.name}')
  </code></pre>
  
  <p><code>testpkg/test/test2.py</code> file content:</p>
  
  <pre><code>from .test1 import Test1
  
  
  def main():
      t = Test1('me')
      t.what_is_your_name()
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p><code>/testpkg/setup.py</code> content:</p>
  
  <pre><code>from setuptools import setup
  
  setup(name='test',
        version='0.1',
        packages=['test'],
        entry_points={
            'console_scripts': [
                'test_exec = test.test2:main'
            ]
        }
        )
  </code></pre>
  
  <p>I can't debug/run <code>test2.py</code> script directly because it gives me error:</p>
  
  <pre><code>» python test/test2.py
  Traceback (most recent call last):
    File "test/test2.py", line 1, in &lt;module&gt;
      from .test1 import Test1
  ModuleNotFoundError: No module named '__main__.test1'; '__main__' is not a package
  </code></pre>
  
  <p>But when i install it with <code>pip install -U .</code></p>
  
  <p>it works:</p>
  
  <pre><code>» pip install -U .
  Processing /home/kossak/Kossak/files_common/PythonProjects/testpkg
  Installing collected packages: test
    Found existing installation: test 0.1
      Uninstalling test-0.1:
        Successfully uninstalled test-0.1
    Running setup.py install for test ... done
  Successfully installed test-0.1
  
  » test_exec
  My name is me
  </code></pre>
  
  <p>The question is: <strong>How to write <code>test2.py</code> properly so it works in both ways - directly (so I can debug it in PyCharm or just run with <code>python test2.py</code>) and after installing the <code>test</code> package?</strong> I tried changing the line:</p>
  
  <pre><code>from .test1 import Test1
  </code></pre>
  
  <p>to</p>
  
  <pre><code>from test1 import Test1
  </code></pre>
  
  <p>(removed dot)</p>
  
  <p>and I can run <code>test2.py</code> from command line, but then after installing, my script "test_exec" gives me error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/kossak/anaconda3/bin/test_exec", line 11, in &lt;module&gt;
      load_entry_point('test==0.1', 'console_scripts', 'test_exec')()
    File "/home/kossak/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 565, in load_entry_point
    File "/home/kossak/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 2598, in load_entry_point
    File "/home/kossak/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 2258, in load
    File "/home/kossak/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 2264, in resolve
    File "/home/kossak/anaconda3/lib/python3.6/site-packages/test/test2.py", line 1, in &lt;module&gt;
      from test1 import Test1
  ModuleNotFoundError: No module named 'test1'
  </code></pre>