diff --git a/flatland/utils/graphics_layer.py b/flatland/utils/graphics_layer.py
index 4dd5179e50cdfb62c335edf14964c9b6118d0d81..327cf4f61605c247538000e83877f9658bbbcad5 100644
--- a/flatland/utils/graphics_layer.py
+++ b/flatland/utils/graphics_layer.py
@@ -2,18 +2,6 @@
 import matplotlib.pyplot as plt
 from numpy import array
 
-import os
-if os.name=='nt':
-    import site
-    import ctypes.util
-    default_os_path = os.environ['PATH']
-    os.environ['PATH'] = ''
-    for s in site.getsitepackages():
-        os.environ['PATH'] = os.environ['PATH'] + ';' + s + '\\cairo'
-    os.environ['PATH'] = os.environ['PATH'] + ';' + default_os_path
-    if ctypes.util.find_library('cairo') is not None:
-        print("cairo installed: OK")
-
 class GraphicsLayer(object):
     def __init__(self):
         pass
diff --git a/flatland/utils/graphics_pil.py b/flatland/utils/graphics_pil.py
index 96951c831e006a6a4585bcd539d0b0b01328e58a..6fb83844ddc66999cf7d4aee33d5f27b8bd0e37e 100644
--- a/flatland/utils/graphics_pil.py
+++ b/flatland/utils/graphics_pil.py
@@ -6,8 +6,21 @@ import numpy as np
 # from flatland.utils.svg import Track, Zug
 import time
 import io
-
-
+import os
+
+def enable_windows_cairo_support():
+    if os.name=='nt':
+        import site
+        import ctypes.util
+        default_os_path = os.environ['PATH']
+        os.environ['PATH'] = ''
+        for s in site.getsitepackages():
+            os.environ['PATH'] = os.environ['PATH'] + ';' + s + '\\cairo'
+        os.environ['PATH'] = os.environ['PATH'] + ';' + default_os_path
+        if ctypes.util.find_library('cairo') is not None:
+            print("cairo installed: OK")
+
+enable_windows_cairo_support()
 from cairosvg import svg2png
 
 from IPython.display import SVG
diff --git a/flatland/utils/rendertools.py b/flatland/utils/rendertools.py
index b8dd5cdead98162de3c6618604fb1260d5caf89b..14a2de1f84f6f7c7c15d1c93821df4b099917870 100644
--- a/flatland/utils/rendertools.py
+++ b/flatland/utils/rendertools.py
@@ -12,6 +12,7 @@ import numpy as np
 
 # TODO: suggested renaming to RailEnvRenderTool, as it will only work with RailEnv!
 
+import os
 
 class MPLGL(GraphicsLayer):
     def __init__(self, width, height):