pythoninterpreter import error
Question: I have problem with importing package in python module. That's what I do:

    
    
    from mega.mega import Mega
    if __name__ == "__main__":
        m = Mega()
    

and from java I run:

    
    
    interpreter.execfile("api.py");
    

But I still get error:

    
    
    Exception in thread "main" Traceback (most recent call last):
    File "<string>", line 1, in <module>
    ImportError: No module named mega
    

In mega folder I have mega.py file and `__init__.py` file to mark this folder
as package.

* * *

Now I get:

    
    
    from mega.mega import Mega
    SyntaxError: ("'import *' not allowed with 'from .'", ...path...
    


Answer: You'll need to add the parent directory of `mega` to `sys.path`:

    
    
    import sys
    import os
    
    PATH = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, PATH)
    
    from mega.mega import Mega
    

`__file__` is the filename of the `api.py` module (can be relative).

