diff --git a/gsl/g4visitor.py b/gsl/g4visitor.py
index <HASH>..<HASH> 100644
--- a/gsl/g4visitor.py
+++ b/gsl/g4visitor.py
@@ -37,7 +37,10 @@ def process(in_file, out_file=None):
 from collections import namedtuple
 
 from gsl.antlr import ParseTreeVisitor
-from .{grammarName}Parser import {grammarName}Parser
+if __name__ is not None and "." in __name__:
+    from .{grammarName}Parser import {grammarName}Parser
+else:
+    from {grammarName}Parser import {grammarName}Parser
 
 """)
         for ruleName, body in rules:
correct generated parser import statement for when the parser is not part of a module