python - 将 .py 编译为 .pyd 时如何修复 "cannot find -lvcruntime140.dll"?

标签 python gcc cython

我正在尝试将我的 python 模块从 .py 转换为 .pyd dll。

每次我尝试执行我的设置脚本时。

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

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

我收到此错误:

c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lvcruntime140.dll
collect2.exe: error: ld returned 1 exit status
error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1

最佳答案

使用以下命令解决了我的问题:

  • 通过 cython 将我的脚本转换为 C 代码:

cython -3 main.py

  • 直接使用gcc将.c转换为.pyd dll:

gcc main.c -o main.pyd -shared -IC:\Python36\include -LC:\Python36\libs -lpython36

关于python - 将 .py 编译为 .pyd 时如何修复 "cannot find -lvcruntime140.dll"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58174343/

相关文章:

python - Django 1.9.2 断言错误 : database connection isn't set to UTC

python - 在 ubuntu 中安装 rpy2 时出错

python 无法导入时区,但可以导入日期时间

c - 如何获取 gcc 的 Ada 规范搜索路径

C 代码在 Eclipse-Kepler 中运行,但在 Codeblocks IDE 中运行失败

python - 使用 Python 数据框从 csv 文件更新数据

c - 如何将程序链接到具有相同函数名称但不同实现的两个库?

python - 在 Python(和 Cython)中计算两个矩阵的点积的最快方法是什么

python - 使用 Cython 提高 Python 函数的性能

python - 将 numpy 数组的切片 View 传递给 cython - 复制发生在哪里?