Index: jsxgraph/JSXCompressor/compress.py
===================================================================
--- jsxgraph.orig/JSXCompressor/compress.py
+++ jsxgraph/JSXCompressor/compress.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 # -*- coding: utf-8 -*-
 '''
     Copyright 2009-2013
@@ -41,5 +41,5 @@ if __name__ == '__main__':
     f = open(filename, "r")
     text = f.read()
     text = base64.b64encode(zlib.compress(urllib.quote(text), 9))
-    print text
+    print(text)
     
Index: jsxgraph/JSXCompressor/decompress.py
===================================================================
--- jsxgraph.orig/JSXCompressor/decompress.py
+++ jsxgraph/JSXCompressor/decompress.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 # -*- coding: utf-8 -*-
 '''
     Copyright 2009-2018
@@ -41,5 +41,5 @@ if __name__ == '__main__':
     f = open(filename, "r")
     text = f.read()
     text = urllib.unquote(zlib.decompress(base64.b64decode(text)))
-    print text
+    print (text)
     
Index: jsxgraph/src/server/jxggroebner.py
===================================================================
--- jsxgraph.orig/src/server/jxggroebner.py
+++ jsxgraph/src/server/jxggroebner.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import numpy
 import os
@@ -41,9 +41,9 @@ import cgi
 
 debugOutput = cStringIO.StringIO()
 
-print "Content-Type: text/plain\n\n"
-print
-print
+print ("Content-Type: text/plain\n\n")
+print()
+print()
 
 # Data required by this script:
 #
@@ -102,8 +102,8 @@ cinput += "EndFor;\n"
 cinput += "Print \"resultsend\", NewLine;"
 
 if debug:
-    print >>debugOutput, "Starting CoCoA with input<br />"
-    print >>debugOutput, cinput + '<br />'
+    print("Starting CoCoA with input<br />", file=debugOutput)
+    print(cinput + '<br />', file=debugOutput)
 
 #cocoa = subprocess.Popen([cmd_cocoa], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
 
@@ -117,7 +117,7 @@ class TimeoutException(Exception): pass
 
 def time_limit(seconds):
     def signal_handler(signum, frame):
-        raise TimeoutException, "Timed out!"
+        raise TimeoutError("Timed out!")
     signal.signal(signal.SIGALRM, signal_handler)
     signal.alarm(seconds)
 
@@ -136,7 +136,7 @@ def callCoCoA():
 try:
     time_limit(time_left)
     callCoCoA()
-except TimeoutException, msg:
+except TimeoutError as  msg:
     # This is only tested with linux/unix
     # and works ONLY if the cocoa script cd-ing
     # to the cocoa dir and starting cocoa executes
@@ -150,7 +150,7 @@ except TimeoutException, msg:
     #subprocess.Popen(["killall", "cocoa_text"])
     #os.system('killall -9 cocoa_text')
     if debug:
-        print >>debugOutput, "Timed out!"
+        print ("Timed out!", file=debugOutput)
     exit()
 
 #cocoa = os.popen("echo \"" + input + "\" | " + cmd_cocoa)
@@ -158,8 +158,8 @@ except TimeoutException, msg:
 #output = cocoa.read()
 
 if debug:
-    print >>debugOutput, "Reading and Parsing CoCoA output" + '<br />'
-    print >>debugOutput, output + '<br />'
+    print ("Reading and Parsing CoCoA output" + '<br />', file=debugOutput)
+    print (output + '<br />', file=debugOutput)
 
 # Extract results
 result = re.split('resultsend', re.split('resultsbegin', output)[1])[0]
@@ -169,9 +169,9 @@ result = result.replace("\r", "")
 polynomials = re.split('\n', result)
 
 if debug:
-    print >>debugOutput, "Found the following polynomials:" + '<br />'
+    print ("Found the following polynomials:" + '<br />', file=debugOutput)
     for i in range(0,len(polynomials)):
-        print >>debugOutput, "Polynomial ", i+1, ": " + polynomials[i] + '<br />'
+        print ("Polynomial ", i+1, ": " + polynomials[i] + '<br />', file=debugOutput)
 
 data = cStringIO.StringIO()
 polynomialsReturn = ""
@@ -195,12 +195,12 @@ for i in range(0,len(polynomials)):
         pa = C.collections[0].get_paths()[i].to_polygons()[0]
 
         for i in range(0,len(pa)):
-            print >>data, pa[i,0], ",", pa[i,1], ";"
+            print (pa[i,0], ",", pa[i,1], ";", file=data)
 
-        print >>data, ";"
+        print (";", file=data)
 
-print >>data, "-----"
-print >>data, polynomialsReturn,";"
+print ("-----", file=data)
+print (olynomialsReturn,";", file=data)
 
 enc_data = base64.b64encode(zlib.compress(data.getvalue(), 9))
 
@@ -210,10 +210,10 @@ if debug:
     fd.close()
 
 if debug:
-    print >>debugOutput, data.getvalue() + '<br />'
-    print debugOutput.getvalue()
+    print (data.getvalue() + '<br />', file=debugOutput)
+    print (debugOutput.getvalue())
 
-print enc_data
+print (enc_data)
 
 data.close()
 debugOutput.close()
Index: jsxgraph/src/server/JXGServer.py
===================================================================
--- jsxgraph.orig/src/server/JXGServer.py
+++ jsxgraph/src/server/JXGServer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 # ZIP compression
 import zlib
@@ -17,9 +17,9 @@ import inspect
 from JXGServerModule import JXGServerModule
 
 def print_httpheader():
-    print """\
+    print ("""\
 Content-Type: text/plain\n
-"""
+""")
 
 
 def default_action(req, resp):
@@ -95,5 +95,5 @@ ret = actions_map.get(action, default_ac
 
 print_httpheader()
 
-print base64.b64encode(zlib.compress(ret, 9))
+print (base64.b64encode(zlib.compress(ret, 9)))
 
Index: jsxgraph/utils/makeexample.py
===================================================================
--- jsxgraph.orig/utils/makeexample.py
+++ jsxgraph/utils/makeexample.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 # -*- coding: utf-8 -*-
 '''
     Copyright 2009-2015
@@ -31,25 +31,25 @@ if __name__ == '__main__':
     space = "     * "
     tab = "    "
     
-    print "%s%s" % (space, "@example")
+    print ("%s%s" % (space, "@example"))
     ''' Print original code '''
     for line in code:
-        print "%s%s" % (space, line.rstrip())
-    print space
+        print ("%s%s" % (space, line.rstrip()))
+    print (space)
     
     uid = uuid.uuid1()
     ''' Print live code '''
-    print "%s%s%s%s" % (space, "</pre><div id=\"", uid, "\" class=\"jxgbox\" style=\"width: 300px; height: 300px;\"></div>")
-    print "%s%s"     % (space, "<script type=\"text/javascript\">")
-    print "%s%s%s"   % (space, tab, "(function() {")
-    print "%s%s%s%s%s"   % (space, tab+tab, "var board = JXG.JSXGraph.initBoard('", uid, "',")
-    print "%s%s%s"   % (space, tab+tab+tab, "{boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});")
+    print ("%s%s%s%s" % (space, "</pre><div id=\"", uid, "\" class=\"jxgbox\" style=\"width: 300px; height: 300px;\"></div>"))
+    print ("%s%s"     % (space, "<script type=\"text/javascript\">"))
+    print ("%s%s%s"   % (space, tab, "(function() {"))
+    print ("%s%s%s%s%s"   % (space, tab+tab, "var board = JXG.JSXGraph.initBoard('", uid, "',"))
+    print ("%s%s%s"   % (space, tab+tab+tab, "{boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});"))
     
     for line in code:
-        print "%s%s%s" % (space, tab, line.rstrip())
-    print space
+        print ("%s%s%s" % (space, tab, line.rstrip()))
+    print (space)
 
-    print "%s%s%s"   % (space, tab, "})();")
-    print "%s"       % (space)
-    print "%s%s"     % (space, "</script><pre>")
-    print space
+    print ("%s%s%s"   % (space, tab, "})();"))
+    print ("%s"       % (space))
+    print ("%s%s"     % (space, "</script><pre>"))
+    print (space)
Index: jsxgraph/examples/bspnc/decompress.py
===================================================================
--- jsxgraph.orig/examples/bspnc/decompress.py
+++ jsxgraph/examples/bspnc/decompress.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 # -*- coding: utf-8 -*-
 '''
     Copyright 2009
@@ -43,4 +43,4 @@ if __name__ == '__main__':
     #text = base64.b64encode(zlib.compress(urllib.quote(text), 9))
     text = urllib.unquote(zlib.decompress(base64.b64decode(text)))
     #text = zlib.decompress(base64.b64decode(text))
-    print text
+    print (text)
Index: jsxgraph/src/server/geoloci.py
===================================================================
--- jsxgraph.orig/src/server/geoloci.py
+++ jsxgraph/src/server/geoloci.py
@@ -109,7 +109,7 @@ class JXGGeoLociModule(JXGServerModule):
 
         def time_limit(seconds):
             def signal_handler(signum, frame):
-                raise TimeoutException, "Timed out!"
+                raise Exception(TimeoutException, "Timed out!")
             signal.signal(signal.SIGALRM, signal_handler)
             signal.alarm(seconds)
 
@@ -126,7 +126,7 @@ class JXGGeoLociModule(JXGServerModule):
         try:
             time_limit(time_left)
             callCoCoA()
-        except TimeoutException, msg:
+        except TimeoutException as msg:
             # This is only tested with linux/unix
             # and works ONLY if the cocoa script cd-ing
             # to the cocoa dir and starting cocoa executes
@@ -198,12 +198,12 @@ class JXGGeoLociModule(JXGServerModule):
         resp.addData('polynomial', polynomialsReturn)
 
         if self.debug:
-            print >>self.debugOutput, ", ".join(map(str, datax)) + '<br />'
-            print >>self.debugOutput, ", ".join(map(str, datay)) + '<br />'
-            print "Content-Type: text/plain\n\n"
-            print
-            print
-            print self.debugOutput.getvalue()
+            print (", ".join(map(str, datax)) + '<br />', file=self.debugOutput)
+            print (", ".join(map(str, datay)) + '<br />', file=self.debugOutput)
+            print ("Content-Type: text/plain\n\n")
+            print()
+            print()
+            print (self.debugOutput.getvalue())
 
         self.debugOutput.close()
 
Index: jsxgraph/src/server/JXGServerModule.py
===================================================================
--- jsxgraph.orig/src/server/JXGServerModule.py
+++ jsxgraph/src/server/JXGServerModule.py
@@ -5,5 +5,5 @@ class JXGServerModule(object):
     def __init__(self):
         self.isJXGServerModule = True
 
-	def init(self, resp):
-		return
+        def init(self, resp):
+            return
