diff --git a/kwant/_system.pyx b/kwant/_system.pyx
index 7e31ed481373b5637a8d485bfa6570f540800b87..d538b09ba1bbc2593bdd36f7a8757fcb7e9306a3 100644
--- a/kwant/_system.pyx
+++ b/kwant/_system.pyx
@@ -12,8 +12,8 @@ import numpy as np
 from scipy import sparse as sp
 from itertools import chain
 
-from kwant.graph.core cimport CGraph, gintArraySlice
-from kwant.graph.defs cimport gint
+from .graph.core cimport CGraph, gintArraySlice
+from .graph.defs cimport gint
 from .graph.defs import gint_dtype
 
 msg = ('Hopping from site {0} to site {1} does not match the '
diff --git a/kwant/graph/core.pxd b/kwant/graph/core.pxd
index 9922d666c8802994f8038e8acfd1afd81eb9a618..5eb7507df3e7b8326c74ff91a4f374e535977ab8 100644
--- a/kwant/graph/core.pxd
+++ b/kwant/graph/core.pxd
@@ -7,7 +7,7 @@
 # http://kwant-project.org/authors.
 
 cimport numpy as np
-from kwant.graph.defs cimport gint
+from .defs cimport gint
 
 cdef struct Edge:
     gint tail, head
diff --git a/kwant/graph/core.pyx b/kwant/graph/core.pyx
index 425e4f221e066a917f55461048842da5e47dead4..e6557bbde467ac98c1fed026d3ee3a3d6dd15de0 100644
--- a/kwant/graph/core.pyx
+++ b/kwant/graph/core.pyx
@@ -30,7 +30,7 @@ from libc.stdlib cimport malloc, realloc, free
 from libc.string cimport memset
 import numpy as np
 cimport numpy as np
-from kwant.graph.defs cimport gint
+from .defs cimport gint
 
 cdef class Graph:
     """An uncompressed graph.  Used to make compressed graphs.  (See `CGraph`.)
diff --git a/kwant/graph/scotch.pyx b/kwant/graph/scotch.pyx
index 0e5dc798aaf5a6ae24aba2e17df0606ce97eb2bc..2fe67196381ef76d5aa0b02797a43fbcd7f43b10 100644
--- a/kwant/graph/scotch.pyx
+++ b/kwant/graph/scotch.pyx
@@ -13,9 +13,9 @@ __all__ = ['bisect', 'reset']
 cimport libc.stdio
 import numpy as np
 cimport numpy as np
-from kwant.graph cimport core
+from . cimport core
 from . import core, defs
-from kwant.graph.c_scotch cimport *
+from .c_scotch cimport *
 
 DEF SCOTCH_STRATQUALITY = 1
 DEF SCOTCH_STRATSPEED = 2
diff --git a/kwant/graph/slicer.pyx b/kwant/graph/slicer.pyx
index fbb45f00a7594971c4ad0983d07ce222f9cd7f48..144719203c85cb02490087501c829938f8707aae 100644
--- a/kwant/graph/slicer.pyx
+++ b/kwant/graph/slicer.pyx
@@ -10,10 +10,10 @@ import numpy as np
 cimport numpy as np
 cimport cython
 from libc.string cimport memcpy
-from kwant.graph.defs cimport gint
+from .defs cimport gint
 from .defs import gint_dtype
-from kwant.graph.core cimport CGraph
-cimport kwant.graph.c_slicer as c_slicer
+from .core cimport CGraph
+from . cimport c_slicer
 
 __all__ = ['slice']
 
diff --git a/kwant/graph/utils.pyx b/kwant/graph/utils.pyx
index 058916a38ada04602ce133790c7170c108ebc71a..fd64fc6695aa527a1ce20126f0ca7394a4e89dfe 100644
--- a/kwant/graph/utils.pyx
+++ b/kwant/graph/utils.pyx
@@ -16,9 +16,9 @@ cimport numpy as np
 from libc.stdlib cimport malloc, realloc, free
 from libc.string cimport memset
 cimport cython
-from kwant.graph.defs cimport gint
+from .defs cimport gint
 from .defs import gint_dtype
-from kwant.graph.core cimport CGraph, CGraph_malloc
+from .core cimport CGraph, CGraph_malloc
 from .core import CGraph, CGraph_malloc
 
 @cython.boundscheck(False)