导入cython的numpy时发生错误。

问题描述 投票:0回答:1

当我在jupyter实验室使用Cython时,发生了一个错误。

%%cython
import numpy as np
cimport numpy as cnp

AttributeError Traceback (最近一次调用) in ----> 1 get_ipython().run_cell_magic('cython', '', 'import numpy as np\ncimport numpy as cnp\n')

D:professional\Anaconda_install\lib/sit-packages/IPython/core/interactiveshell.py中的run_cell_magic(self, magic_name, line, cell) 2360 with self.buildin_trap: 2361 args = (magic_arg_s, cell) -> 2362 result = fn(*args, **kwargs) 2363 return result 2364

在cython(self, line, cell)中

D:\professional\Anaconda_install\lib\sit-packages\IPython\core\magic.py in (f, *a, **k) 185 # 但它对于仅仅那一点状态来说是过度的。 186 def magic_deco(arg): --> 187 call = lambda f, *a, **k: f(*a, **k) 188 189 if callable(arg):

D:professional/Anaconda_install/lib/sitake-packages/Cython/Build/IpythonMagic.py in cython(self, line, cell) 331 extension = None 332 if need_cythonize: --> 333 extensions = self._cythonize(module_name, code, lib_dir, args, quiet=args.quiet) 334 if extensions is None: 335 # 编译失败并打印错误信息。

D:专业/Anaconda_install/lib/sit-packages/Cython/Build/IpythonMagic.py in _cythonize(self, module_name, code, lib_dir, args, quiet) 422 如果 code 中有 'numpy'。 423 import numpy --> 424 c_include_dirs.append(numpy.get_include() 425 with io.open(pyx_file, 'w', encoding='utf-8') as f: 426 f.write(code)

AttributeError: 模块'numpy'没有属性'get_include'。

我的numpy版本是1.17.2,而且没有任何的 include 文件夹中 D:\professional\Anaconda_install\Lib\site-packages\numpy\core.有人知道如何解决这个问题吗?谢谢!

python numpy cython
1个回答
0
投票

不好意思,给大家添麻烦了。我刚刚发现numpy包崩溃了,这个错误与cython无关。卸载重装numpy后,问题就可以解决了。

© www.soinside.com 2019 - 2024. All rights reserved.