尝试构建Cython文件 - 出现错误(Python 2.7,Windows 7 64位)

0 投票
1 回答
975 浏览
提问于 2025-04-17 14:34

我在Windows Powershell里使用Python 2.7(我已经设置好环境,可以使用Python)。

我安装了Cython(是用Windows安装程序安装的)。

我正在按照Cython网站上的教程,想做一个简单的“Hello World”扩展,但当我尝试构建这个扩展时,出现了这个错误:

dllwrap: gcc exited with status 1
error: command 'dllwrap' failed with exit status 1

我该怎么解决这个问题,以便我可以通过C扩展来优化我的Python代码呢?

1 个回答

0

这是错误代码的其余部分:

Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\Pinky> cd Programming
PS C:\Users\Pinky\Programming> python setup.py build_ext --inplace
running build_ext
skipping 'helloworld.c' Cython extension (up-to-date)
building 'helloworld' extension
C:\MinGW\bin\gcc.exe -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c helloworld.c -o build\temp.win32-2.7\Relea
se\helloworld.o
writing build\temp.win32-2.7\Release\helloworld.def
C:\MinGW\bin\dllwrap.exe -mdll -static --output-lib build\temp.win32-2.7\Release\libhelloworld.a --def build\temp.win32-
2.7\Release\helloworld.def -s build\temp.win32-2.7\Release\helloworld.o -LC:\Python27\libs -LC:\Python27\PCbuild -lpytho
n27 -lmsvcr90 -o C:\Users\Pinky\Programming\helloworld.pyd
helloworld.exp: file not recognized: File format not recognized
collect2: ld returned 1 exit status
dllwrap: gcc exited with status 1
error: command 'dllwrap' failed with exit status 1
PS C:\Users\Pinky\Programming>

撰写回答