即使在 WSL2.0 Ubuntu 22.04 上安装了 cython,也没有名为 Cython.Build 的模块

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

我正在使用 Ubuntu 22.04 到 WSL 2.0。我已经通过 Anaconda 安装了 Python,并使用版本 2024.02-1。
我目前正在尝试启动并运行 Cython,但遇到了问题。我正在运行 Cython 网站上的基本“Hello World”示例 (https://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html)。

我拥有的文件之一是

setup.py
,看起来像这样:
但是,当我运行
python setup.py build_ext --inplace
时,我收到一条错误消息,指出找不到
Cython.build
模块。这很奇怪,因为我可以
import cython
绝对没问题。

此页面有很多建议(https://github.com/CellProfiler/centrosome/issues/78),但它们似乎都等于未安装 Cython,但对我来说并非如此。

还有其他人经历过(并解决过)这个问题吗?

python
1个回答
0
投票

从 setuptools 导入设置 从 Cython.Build 导入 cythonize

设置( ext_modules = cythonize("helloworld-pyx") )

使用它代替 Cython.build 使用 Cython.Build

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