Python %Windows链接器上带Anaconda分发版的cython错误:命令';gcc&x27;失败,退出状态为1

Python %Windows链接器上带Anaconda分发版的cython错误:命令';gcc&x27;失败,退出状态为1,python,windows,gcc,cython,ipython-notebook,Python,Windows,Gcc,Cython,Ipython Notebook,我已经看到了这个错误的类似答案,但我的是一个链接错误,所以我认为解决这个问题可能有点不同。除此之外,所有这些看似相似的错误的答案都是不同的 我试图通过ipython笔记本使用cython: %load_ext cythonmagic %%cython cdef double f_typed(double x): return x * (x - 1) cpdef double integrate_f_typed(double a, double b, int N): cdef in

我已经看到了这个错误的类似答案,但我的是一个链接错误,所以我认为解决这个问题可能有点不同。除此之外,所有这些看似相似的错误的答案都是不同的

我试图通过ipython笔记本使用cython:

%load_ext cythonmagic
%%cython
cdef double f_typed(double x):
    return x * (x - 1)
cpdef double integrate_f_typed(double a, double b, int N):
    cdef int i
    cdef double s, dx
    s = 0
    dx = (b - a) / N
    for i in range(N):
        s += f_typed(a + i * dx)
    return s * dx
但鉴于错误,似乎有些东西没有正确链接。。。不知道去哪里看或者做什么

以下是错误日志:

---------------------------------------------------------------------------
LinkError                                 Traceback (most recent call last)
<ipython-input-6-b9b32dd293fb> in <module>()
----> 1 get_ipython().run_cell_magic(u'cython', u'', u'cdef double f_typed(double x):\n    return x * (x - 1)\ncpdef double integrate_f_typed(double a, double b, int N):\n    cdef int i\n    cdef double s, dx\n    s = 0\n    dx = (b - a) / N\n    for i in range(N):\n        s += f_typed(a + i * dx)\n    return s * dx')

C:\Anaconda\lib\site-packages\IPython\core\interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
   2160             magic_arg_s = self.var_expand(line, stack_depth)
   2161             with self.builtin_trap:
-> 2162                 result = fn(magic_arg_s, cell)
   2163             return result
   2164 

C:\Anaconda\lib\site-packages\IPython\extensions\cythonmagic.pyc in cython(self, line, cell)

C:\Anaconda\lib\site-packages\IPython\core\magic.pyc in <lambda>(f, *a, **k)
    191     # but it's overkill for just that one bit of state.
    192     def magic_deco(arg):
--> 193         call = lambda f, *a, **k: f(*a, **k)
    194 
    195         if callable(arg):

C:\Anaconda\lib\site-packages\IPython\extensions\cythonmagic.pyc in cython(self, line, cell)
    266             build_extension.build_temp = os.path.dirname(pyx_file)
    267             build_extension.build_lib  = lib_dir
--> 268             build_extension.run()
    269             self._code_cache[key] = module_name
    270 

C:\Anaconda\lib\distutils\command\build_ext.pyc in run(self)
    337 
    338         # Now actually compile and link everything.
--> 339         self.build_extensions()
    340 
    341     def check_extensions_list(self, extensions):

C:\Anaconda\lib\distutils\command\build_ext.pyc in build_extensions(self)
    446 
    447         for ext in self.extensions:
--> 448             self.build_extension(ext)
    449 
    450     def build_extension(self, ext):

C:\Anaconda\lib\distutils\command\build_ext.pyc in build_extension(self, ext)
    528             debug=self.debug,
    529             build_temp=self.build_temp,
--> 530             target_lang=language)
    531 
    532 

C:\Anaconda\lib\distutils\ccompiler.pyc in link_shared_object(self, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, export_symbols, debug, extra_preargs, extra_postargs, build_temp, target_lang)
    689                   libraries, library_dirs, runtime_library_dirs,
    690                   export_symbols, debug,
--> 691                   extra_preargs, extra_postargs, build_temp, target_lang)
    692 
    693     def link_executable(self, objects, output_progname, output_dir=None,

C:\Anaconda\lib\distutils\cygwinccompiler.pyc in link(self, target_desc, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, export_symbols, debug, extra_preargs, extra_postargs, build_temp, target_lang)
    258                            extra_postargs,
    259                            build_temp,
--> 260                            target_lang)
    261 
    262     # link ()

C:\Anaconda\lib\distutils\unixccompiler.pyc in link(self, target_desc, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, export_symbols, debug, extra_preargs, extra_postargs, build_temp, target_lang)
    198                 self.spawn(linker + ld_args)
    199             except DistutilsExecError, msg:
--> 200                 raise LinkError, msg
    201         else:
    202             log.debug("skipping %s (up-to-date)", output_filename)

LinkError: command 'gcc' failed with exit status 1
---------------------------------------------------------------------------
链接错误回溯(上次最近的调用)
在()
---->1 get_ipython().运行单元格\u magic(u'cython',u'',u'cdef double f_类型化(double x):\n返回x*(x-1)\ncpdef double integration\u f类型化(double a,double b,int n):\n cdef int i\n cdef double s,dx\n s=0\n dx=(b-a)/n\n对于范围内的i:\n s+=f_类型化(a+i*dx)\n返回s*dx')
C:\Anaconda\lib\site packages\IPython\core\interactiveshell.pyc in run\u cell\u magic(self,magic\u name,line,cell)
2160 magic_arg_s=self.var_expand(行、堆栈深度)
2161带自建存水弯:
->2162结果=fn(魔法参数,单元格)
2163返回结果
2164
C:\Anaconda\lib\site packages\IPython\extensions\cythonmagic.pyc在cython中(self、line、cell)
C:\Anaconda\lib\site packages\IPython\core\magic.pyc in(f,*a,**k)
191#但这一点对国家来说太过分了。
192 def魔术装饰(arg):
-->193调用=λf,*a,**k:f(*a,**k)
194
195如果可调用(arg):
C:\Anaconda\lib\site packages\IPython\extensions\cythonmagic.pyc在cython中(self、line、cell)
266 build_extension.build_temp=os.path.dirname(pyx_文件)
267 build\u extension.build\u lib=lib\u dir
-->268 build_extension.run()
269 self.\u code\u cache[key]=模块名称
270
C:\Anaconda\lib\distutils\command\build\u ext.pyc正在运行(self)
337
338#现在实际编译并链接所有内容。
-->339自我构建扩展()
340
341 def检查扩展列表(自身、扩展):
C:\Anaconda\lib\distutils\command\build\u ext.pyc in build\u extensions(self)
446
447对于self.extensions中的ext:
-->448自构建扩展(ext)
449
450 def构建扩展(自身、外部):
C:\Anaconda\lib\distutils\command\build\u ext.pyc in build\u extension(self,ext)
528 debug=self.debug,
529构建温度=自构建温度,
-->530目标(语言)
531
532
C:\Anaconda\lib\distutils\ccompiler.pyc在link\u shared\u对象(self、objects、output\u filename、output\u dir、libraries、library\u dirs、runtime\u library\u dirs、export\u符号、debug、extra\u preargs、extra\u postargs、build\u temp、target\u lang)中
689库,库目录,运行库目录,
690导出_符号,调试,
-->691额外预加、额外后加、构建温度、目标温度)
692
693 def link_可执行文件(self、objects、output_progname、output_dir=None、,
链接中的C:\Anaconda\lib\distutils\cygwingcompiler.pyc(self、target\u desc、objects、output\u filename、output\u dir、libraries、library\u dirs、runtime\u library\u dirs、export\u symbols、debug、extra\u preargs、extra\u postargs、build\u temp、target\u lang)
258额外邮资,
259建筑温度,
-->260目标(乌朗)
261
262链接()
链接中的C:\Anaconda\lib\distutils\unixcompiler.pyc(self、target\u desc、objects、output\u filename、output\u dir、libraries、library\u dirs、runtime\u library\u dirs、export\u符号、debug、extra\u preargs、extra\u postargs、build\u temp、target\u lang)
198自我繁殖(链接器+ld_参数)
199除DistutilsExecError外,msg:
-->200提升链接器错误,msg
201其他:
202 log.debug(“跳过%s(最新)”,输出文件名)
链接器错误:命令“gcc”失败,退出状态为1
我正在使用:
Cython 0.20和gcc 4.7(与Anaconda python发行版一起安装)以及Windows 7上的python 2.7.5

在启动IPython笔记本的终端窗口中,您看到了什么输出?编译器的输出经常被重定向到那里。我昨天才发现问题与单独安装mingw有关,而mingw已经包含在Anaconda发行版中。我所做的就是重新安装Anaconda,一切都很顺利