py27 编译 pyd 问题请教

2020-04-21 22:54:22 +08:00
 oldbird

参照了这篇文章 http://yshblog.com/blog/117

主要就是 1 、安装微软为 Python 提供了专用的编译器 Microsoft Visual C++ Compiler for Python 2.7 2 、修改 python 安装目录下 Lib\distutils\msvc9compiler.py 文件,找到 get_build_version 方法直接 return 9.0 ;然后再找到 find_vcvarsall 方法直接返回 vcvarsall.bat 的路径

运行 python setup.py build_ext --inplace 后,总是提示

running build_ext

building 'test' extension

gcc -mno-cygwin -mdll -O -Wall -IC:\Wpy\WPy27_32\python-2.7.13\include -IC:\Wpy\WPy27_32\python-2.7.13\PC -c test.c -o build\temp.win32-2.7\Release\test.o

error: command 'gcc' failed: No such file or directory

不知道哪里去找 gcc,必须要安装?

1705 次点击
所在节点    Python
3 条回复
ysc3839
2020-04-22 05:55:58 +08:00
你是想学习编译流程本身,还是想编译出一个 pyd ?如果是后者的话建议直接使用 pybind11 。
https://github.com/pybind/pybind11
oldbird
2020-04-22 07:01:45 +08:00
就是想编译一个 pyd,看博客帖子好像不需要 gcc,只要安装微软支持库,不知道为什么报错
SingeeKing
2020-04-22 12:26:50 +08:00
你确定是在 Microsoft Visual C++ Compiler for Python 2.7 2 环境内运行的吗,试试直接执行 gcc -v 有没有版本信息

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/664798

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX