Cython in Ipython: ERROR: Cell magic `%%cython` not found
Cython in Ipython: ERROR: Cell magic `%%cython` not found
在 ipython 笔记本中使用 cython
时,我看到以下错误。怎么了?
%load_ext cythonmagic
/usr/local/lib/python2.7/dist-packages/IPython/extensions/cythonmagic.py:21: UserWarning: The Cython magic has been moved to the Cython package
warnings.warn("""The Cython magic has been moved to the Cython package""")
%%cython
def fib(int n):
cdef int a,b,i
for i in range(n):
a,b=a+b,b
return a
ERROR: Cell magic `%%cython` not found.
警告试图传达的是,定义 %%cython
魔法的扩展已从 IPython 包移至 Cython 包。所以而不是
%load_ext cythonmagic
你应该做的:
%load_ext Cython
在那之后,cython 魔法应该会按预期工作。
记得在不同的单元格中加载扩展。
如果您在同一个单元格中加载和使用 Cython 扩展,您将出错:
使用相同的单元格:
使用不同的单元格:
在 ipython 笔记本中使用 cython
时,我看到以下错误。怎么了?
%load_ext cythonmagic
/usr/local/lib/python2.7/dist-packages/IPython/extensions/cythonmagic.py:21: UserWarning: The Cython magic has been moved to the Cython package
warnings.warn("""The Cython magic has been moved to the Cython package""")
%%cython
def fib(int n):
cdef int a,b,i
for i in range(n):
a,b=a+b,b
return a
ERROR: Cell magic `%%cython` not found.
警告试图传达的是,定义 %%cython
魔法的扩展已从 IPython 包移至 Cython 包。所以而不是
%load_ext cythonmagic
你应该做的:
%load_ext Cython
在那之后,cython 魔法应该会按预期工作。
记得在不同的单元格中加载扩展。
如果您在同一个单元格中加载和使用 Cython 扩展,您将出错:
使用相同的单元格:
使用不同的单元格: