2016-08-04 45 views
5

Ich bekomme Fehler beim Laden einer Cython-Datei in Jupyter Notebook. Irgendwelche Ideen?Cython in Jupyter Notebook

%load_ext Cython 

import numpy as np 
cimport numpy as np 
import cython 

Nur eine einfache Fehlermeldung:

File "<ipython-input-3-7e39dc7f561b>", line 5 
    cimport numpy as np 
       ^
SyntaxError: invalid syntax 
+1

Sie cython Code in speziellen magischen Zellen verwenden. Sie definieren eine Cython-Zelle, indem Sie Ihre Zelle mit '%% cython' starten. – cel

+0

' 'ERROR: Cell magic' %% cython' not found.''' –

Antwort

11

Nach dem docs Lesen - ich verwendet, um zwei getrennte Zellen. Die erste ist einfach:

%load_ext Cython 

Dann meine Import-Anweisungen

%%cython 

import numpy as np 
cimport numpy as np 
import cython