【问题标题】:Can't install Kivy: Cython/GCC error无法安装 Kivy:Cython/GCC 错误
【发布时间】:2012-11-09 05:42:44
【问题描述】:

所以我尝试按照官方网站的说明安装 Kivy:

$ sudo apt-get install python-setuptools python-pygame python-opengl \
  python-gst0.10 python-enchant gstreamer0.10-plugins-good python-dev \
  build-essential libgl1-mesa-dev libgles2-mesa-dev python-pip

$ sudo pip install --upgrade cython

$ sudo easy_install kivy

这是我得到的:

Searching for kivy
Reading http://pypi.python.org/simple/kivy/
Best match: Kivy 1.4.1
Downloading http://pypi.python.org/packages/source/K/Kivy/Kivy-1.4.1.tar.gz#md5=94bba894269e4bdecc7881f256367e01
Processing Kivy-1.4.1.tar.gz
Running Kivy-1.4.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-MMi2Fv/Kivy-1.4.1/egg-dist-tmp-EcKbfC
[INFO   ] Kivy v1.4.1
Found GLES 2.0 headers at /usr/include/GLES2/gl2.h
Build configuration is:
 * use_opengl_es2  =  True
 * use_glew  =  False
 * use_opengl_debug  =  False
 * use_mesagl  =  False
Generate config.h
Generate config.pxi
/tmp/easy_install-MMi2Fv/Kivy-1.4.1/kivy/graphics/transformation.c: In function ‘__pyx_f_4kivy_8graphics_14transformation_6Matrix_identity’:
/tmp/easy_install-MMi2Fv/Kivy-1.4.1/kivy/graphics/transformation.c:2774:13: error: incompatible types when assigning to type ‘__pyx_t_4kivy_8graphics_14transformation_matrix_t’ from type ‘double *’
/tmp/easy_install-MMi2Fv/Kivy-1.4.1/kivy/graphics/transformation.c: In function ‘__pyx_f_4kivy_8graphics_14transformation_6Matrix_inverse’:
/tmp/easy_install-MMi2Fv/Kivy-1.4.1/kivy/graphics/transformation.c:2978:13: error: incompatible types when assigning to type ‘__pyx_t_4kivy_8graphics_14transformation_matrix_t’ from type ‘double *’
/tmp/easy_install-MMi2Fv/Kivy-1.4.1/kivy/graphics/transformation.c:2980:13: error: incompatible types when assigning to type    ‘__pyx_t_4kivy_8graphics_14transformation_matrix_t’ from type ‘double *’
/tmp/easy_install-MMi2Fv/Kivy-1.4.1/kivy/graphics/transformation.c: In function ‘__pyx_f_4kivy_8graphics_14transformation_6Matrix_multiply’:
/tmp/easy_install-MMi2Fv/Kivy-1.4.1/kivy/graphics/transformation.c:3364:13: error: incompatible types when assigning to type ‘__pyx_t_4kivy_8graphics_14transformation_matrix_t’ from type ‘double *’
/tmp/easy_install-MMi2Fv/Kivy-1.4.1/kivy/graphics/transformation.c:3366:13: error: incompatible types when assigning to type ‘__pyx_t_4kivy_8graphics_14transformation_matrix_t’ from type ‘double *’
/tmp/easy_install-MMi2Fv/Kivy-1.4.1/kivy/graphics/transformation.c:3368:13: error: incompatible types when assigning to type ‘__pyx_t_4kivy_8graphics_14transformation_matrix_t’ from type ‘double *’
/tmp/easy_install-MMi2Fv/Kivy-1.4.1/kivy/graphics/transformation.c: In function ‘__pyx_pf_4kivy_8graphics_14transformation_6Matrix_20__str__’:
/tmp/easy_install-MMi2Fv/Kivy-1.4.1/kivy/graphics/transformation.c:3674:13: error: incompatible types when assigning to type ‘__pyx_t_4kivy_8graphics_14transformation_matrix_t’ from type ‘double *’
 error: Setup script exited with error: command 'gcc' failed with exit status 1

在网上找不到答案后,我开始调查产生错误的文件:transformation.c、transformation.pyx 和 transformation.pyd。我还阅读了一些关于 Cython 的文章。

首先,所有错误都属于同一类型:

error: incompatible types when assigning to type ‘__pyx_t_4kivy_8graphics_14transformation_matrix_t’ from type ‘double *’

这里出现第一个错误:

__pyx_t_3 = __pyx_v_self->mat;

__pyx_t_3的类型是:

__pyx_t_4kivy_8graphics_14transformation_matrix_t

它有这个奇怪的名字,因为它是从 transformation.pxd 文件中自动生成的:

ctypedef double matrix_t[16]

所以,type(__pyx_t_3) == type(matrix_t) == double *.

__pyx_v_self的类型是:

struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *

同样,它是从 transformation.pxd 生成的:

ctypedef double matrix_t[16]

cdef class Matrix:
    cdef matrix_t mat
    ...

因此,type(__pyx_v_self->mat) == type(Matrix.mat) == type(matrix_t) == double *

我们可以看到,赋值的两边:

__pyx_t_3 = __pyx_v_self->mat;

属于 (double *) 类型。

为什么会出现这个错误:

error: incompatible types when assigning to type ‘__pyx_t_4kivy_8graphics_14transformation_matrix_t’ from type ‘double *’

然后被抚养?

编译器似乎没有将 ma​​trix_t 的类型识别为双 *。

【问题讨论】:

    标签: python c gcc cython kivy


    【解决方案1】:

    刚刚遇到同样的错误。使用 Cython 0.17.1 对我有帮助:

    sudo pip install Cython==0.17.1
    

    如果您不只是想解决问题,您可以深入检查这两个版本之间的更改。 https://github.com/cython/cython/blob/master/CHANGES.rst#0172-2012-11-20 - 在这里你可以找到相关的问题,但不幸的是我不是 C/Cython 的专家,快速浏览一下 master 和 0.17.1 之间的差异并没有告诉我问题出在哪里,但如果你愿意的话自己调查问题。

    【讨论】:

    • 天哪,我不敢相信它成功了!我最初使用的是旧版本的 Cython,然后我将它升级到最新版本:0.17.2,我从来没有想过我应该有一个旧版本来让它工作。非常感谢!
    • 我收到了这个错误:#error Do not use this file, it is the result of a failed Cython compilation error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 并且修复了它。谢谢! +1
    【解决方案2】:

    我也遇到了同样的错误。我将其追溯到一个小示例,并向 Cython 邮件列表发送了一封电子邮件:https://groups.google.com/forum/?fromgroups=#!topic/cython-users/fSZgHqrlCOc

    【讨论】:

      猜你喜欢
      • 2013-11-30
      • 1970-01-01
      • 2011-05-25
      • 2011-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-25
      • 2012-08-03
      相关资源
      最近更新 更多