我刚刚使用 Anaconda/Condas 在 Windows 7 64 位计算机上安装了 Python 3.4。
当我运行“你好世界”cython 示例 http://docs.cython.org/src/quickstart/build.html#building-a-cython-module-using-distutils我收到此错误:
[py34] C:\Users\Jon\Documents\GitHub\CythonFunctions\cython_funcs>python setup.py build_ext --inplace
running build_ext
building 'cython_funcs.hello' extension
C:\Anaconda\envs\py34\MinGW\bin\gcc.exe -mdll -O -Wall -IC:\Anaconda\envs\py34\include -IC:\Anaconda\envs\py34\include -c hello.c -o build\temp.win-amd64-3.4\Release\hello.o
writing build\temp.win-amd64-3.4\Release\hello.def
C:\Anaconda\envs\py34\MinGW\bin\gcc.exe -shared -s build\temp.win-amd64-3.4\Release\hello.o build\temp.win-amd64-3.4\Release\hello.def -LC:\Anaconda\envs\py34\libs -LC:\Anaconda\envs\py34\PCbuild\amd6
4 -lpython34 -lmsvcr100 -o C:\Users\Jon\Documents\GitHub\CythonFunctions\cython_funcs\cython_funcs\hello.pyd
build\temp.win-amd64-3.4\Release\hello.o:hello.c:(.text+0x314): undefined reference to `__imp__PyThreadState_Current'
build\temp.win-amd64-3.4\Release\hello.o:hello.c:(.text+0x493): undefined reference to `__imp__Py_NoneStruct'
build\temp.win-amd64-3.4\Release\hello.o:hello.c:(.text+0x97b): undefined reference to `__imp_PyExc_ImportError'
collect2.exe: error: ld returned 1 exit status
error: command 'C:\\Anaconda\\envs\\py34\\MinGW\\bin\\gcc.exe' failed with exit status 1
通过搜索 stackoverflow 和 google,当 gcc 和 python 版本既不是 32 位也不是 64 位时,就会出现此错误。
我检查过我的Python是64位的。从下面的路径可以看出,我拥有的 MinGW 是我的 Python 安装的一部分。如何检查是否是 64 位?或者这个错误可能是由于其他原因造成的?
Update:
奇怪的是,这里的 Ipython cythonmagic 命令工作正常:
http://docs.cython.org/src/quickstart/build.html?highlight=cythonmagic http://docs.cython.org/src/quickstart/build.html?highlight=cythonmagic
一种方法是conda remove libpython
(这将导致 distutils 不使用 mingw),然后安装 Visual Studio 2010,并使用它进行编译。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)