python - 使用 Jupyter Notebook 在 Cython 中的 unordered_set
问题描述
我一直试图在我的 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: command 'gcc' failed with exit status 1
解决方案
Older gcc versions don't use c++-11 (but c++-98) per default, and because unordered_map
is a c++11-feature, you need to pass the option to the compiler.
For example via:
%%cython -a -3 -c=-std=c++11
Or update your gcc to 6.0 or above.
推荐阅读
- php - preg_match 匹配一个以 all 开头和结尾的单词
- node.js - ts-node-dev 遇到错误:“找不到模块'typescript'”
- spring-mvc - tomcat 和 springMVC
- node.js - TypeError:无法读取未定义的属性“角色” - 输入被错误读取
- python - 在 python 中拟合 SARIMA 模型时如何包含常量/截距
- rust - 生命周期阻碍状态机返回到最近的状态
- angular - 看不到值来自服务的变量的出价
- java - java的标准网络API与netty有何不同?
- postgresql - 我正在尝试从表中提取国家信息,但无法在 postgresql 中进行
- webauthn - WebAuthn 身份验证器证明响应 id 和 rawId