imports python3 in another folder
<p>When I run launch.py it fails and when I run main.py directly it works.
launch.py just imports and runs main.py. Why?</p>

<pre><code>âââ dir
âÂ Â  âââ bla.py
âÂ Â  âââ __init__.py
âÂ Â  âââ main.py
âââ __init__.py
âââ launch.py

launch.py
---------
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-

    from dir import main
    main.main()

main.py
-------

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    import bla
    bla.pront()


bla.py
------

def pront():
    print('pront')
</code></pre>

<p>EDITED:</p>

<p><a href="http://i.stack.imgur.com/cgfvU.png" rel="nofollow">enter image description here</a></p>

<p>Using your layout and with the following files, we don't have problems.</p>

<h3>launch.py</h3>

<pre><code>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from dir import main

if __name__ == "__main__":
   main. main()
</code></pre>

<h3>main.py</h3>

<pre><code>#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
    from . import bla
except:
    import bla

def main():
    bla.pront()

if __name__ == "__main__":
    main()
</code></pre>

<p>The <code>try ... except</code> structure is used in case the <strong><em>main.py</em></strong> was used inside or outside the package.</p>

<p>Of course, there is a lot of info about it. You can start with <a href="http://stackoverflow.com/questions/16981921/relative-imports-in-python-3">this</a>.</p>

python import module folder