我正在尝试将我的 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/