在jupyter笔记本中的cython

时间:2016-08-04 13:24:50

标签: ipython cython jupyter-notebook

在Jupyter Notebook中加载Cython文件时遇到错误。有什么想法吗?

%load_ext Cython

import numpy as np
cimport numpy as np
import cython

只是一条简单的错误消息:

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

1 个答案:

答案 0 :(得分:13)

阅读docs后 - 我使用了两个单独的单元格。第一个是:

%load_ext Cython

然后我的导入语句

%%cython

import numpy as np
cimport numpy as np
import cython