diff --git a/napi/__init__.py b/napi/__init__.py
index <HASH>..<HASH> 100644
--- a/napi/__init__.py
+++ b/napi/__init__.py
@@ -44,12 +44,17 @@ class String(str):
 nsource = String(open(os.path.join(imp.find_module('napi')[1],
                                   'functions.py')).read())
 
+
+def register_magic():
+
+    from .magics import NapiMagics
+    ip = get_ipython()
+    if ip is not None:
+        ip.register_magics(NapiMagics(ip))
+
 try:
     from IPython import get_ipython
 except ImportError:
     pass
 else:
-    from .magics import NapiMagics
-    ip = get_ipython()
-    if ip is not None:
-        ip.register_magics(NapiMagics(ip))
\ No newline at end of file
+    register_magic()
\ No newline at end of file
Added register_magic function.