gpt4 book ai didi

ipython - Ipython 中的 Cython : ERROR: Cell magic `%%cython` not found

转载 作者:行者123 更新时间:2023-12-01 23:33:39 26 4
gpt4 key购买 nike

在 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 魔法应该按预期工作。

关于ipython - Ipython 中的 Cython : ERROR: Cell magic `%%cython` not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36514338/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com