首页 > 解决方案 > 我得到 ModuleNotFoundError: No module named 'Cython' 尝试制作扩展时

问题描述

我正在尝试运行此代码:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [
    Extension("sum",  ["a123.pyx"])]

setup(
    name = 'app',
    cmdclass = {'build_ext': build_ext},
    ext_modules = ext_modules
)

我得到了这个错误:

Traceback (most recent call last):
  File "compile.py", line 3, in <module>
    from Cython.Distutils import build_ext
ImportError: No module named 'Cython'

我正在使用 Conda 并且我添加了 cython 我也在我的系统中安装 cython。但错误无法修复!

标签: pythonmodulecythoncpython

解决方案


它已通过在 conda 中卸载 cython 并重新安装来修复!

卸载:

conda uninstall cython

重新安装:

conda install -c anaconda cython

推荐阅读