gpt4 book ai didi

python - 使用 Jupyter Notebook 在 Cython 中设置 unordered_set

转载 作者:行者123 更新时间:2023-12-01 01:18:55 27 4
gpt4 key购买 nike

我试图在 Mac 上的 Jupyter Notebook 中的 Cython 中使用 unordered_sets。

%%cython -a -3
# distutils: language = c++
# cython: c_string_type=unicode, c_string_encoding=utf8
import cython
from libcpp.unordered_set cimport unordered_set

def test():
cdef unordered_set[int] s
return s

上面的单元格抛出:DistutilsExecError:命令“gcc”失败,退出状态为 1

最佳答案

较旧的 gcc 版本默认不使用 c++-11(而是 c++-98),并且由于 unordered_map 是 c++11 功能,因此您需要将该选项传递给编译器。

例如通过:

%%cython -a -3 -c=-std=c++11

或者将您的 gcc 更新为 6.0 or above.

关于python - 使用 Jupyter Notebook 在 Cython 中设置 unordered_set,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54028709/

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