weixin_41083119 2018-09-05 08:58 采纳率: 0%
浏览 6401
已结题

最简单cython编译出现问题,大神求帮忙

在使用cython编译最简单的helloworld程序时出现如下问题:
本人使用的是anaconda3+vs2015

Compiling helloworld.pyx because it changed.
[1/1] Cythonizing helloworld.pyx
running build_ext
Traceback (most recent call last):
  File "setup.py", line 5, in <module>
    ext_modules = cythonize("helloworld.pyx")
  File "D:\anaconda\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "D:\anaconda\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "D:\anaconda\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "D:\anaconda\lib\distutils\command\build_ext.py", line 308, in run
    force=self.force)
  File "D:\anaconda\lib\distutils\ccompiler.py", line 1031, in new_compiler
    return klass(None, dry_run, force)
  File "D:\anaconda\lib\distutils\cygwinccompiler.py", line 285, in __init__
    CygwinCCompiler.__init__ (self, verbose, dry_run, force)
  File "D:\anaconda\lib\distutils\cygwinccompiler.py", line 129, in __init__
    if self.ld_version >= "2.10.90":
TypeError: '>=' not supported between instances of 'NoneType' and 'str'

helloworld.pyx文件中的代码

 print('hello world')

setup.py中代码

 from distutils.core import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("helloworld.pyx")
)
  • 写回答

5条回答 默认 最新

  • threenewbee 2018-09-05 15:28
    关注

    看了下代码中的注释:

             self.gcc_version, self.ld_version, self.dllwrap_version = \
                get_versions()
            self.debug_print(self.compiler_type + ": gcc %s, ld %s, dllwrap %s\n" %
                             (self.gcc_version,
                              self.ld_version,
                              self.dllwrap_version) )
    
            # ld_version >= "2.10.90" and < "2.13" should also be able to use
            # gcc -mdll instead of dllwrap
            # Older dllwraps had own version numbers, newer ones use the
            # same as the rest of binutils ( also ld )
            # dllwrap 2.10.90 is buggy
            if self.ld_version >= "2.10.90":
                self.linker_dll = "gcc"
            else:
                self.linker_dll = "dllwrap"
    

    感觉你应该最好用gcc来编译,而不是vc++,因为后者版本号的格式和这个判断不兼容。
    或者你试试看修改cygwinccompiler.py文件,把这个判断注释下。

    评论

报告相同问题?

悬赏问题

  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试