Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cython in jupyter notebook

I am getting errors when loading a Cython file in Jupyter Notebook. Any ideas?

%load_ext Cython

import numpy as np
cimport numpy as np
import cython

Just a simple error message:

File "<ipython-input-3-7e39dc7f561b>", line 5
    cimport numpy as np
                ^
SyntaxError: invalid syntax
like image 885
john mangual Avatar asked Aug 04 '16 13:08

john mangual


1 Answers

After reading the docs -- I used two separate cells. The first one is just:

%load_ext Cython

Then my import statements

%%cython

import numpy as np
cimport numpy as np
import cython
like image 78
john mangual Avatar answered Oct 20 '22 00:10

john mangual