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 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法