简体   繁体   English

无法安装Kivy:Cython / GCC错误

[英]Can't install Kivy: Cython/GCC error

so I tried to install Kivy following the instructions from the official site: 所以我尝试按照官方网站的说明安装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

This is what I get: 这就是我得到的:

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

After failing to find an answer in the web I began to investigate the files which generated the error: transformation.c, transformation.pyx and transformation.pyd. 在网络中找不到答案后,我开始研究产生错误的文件:transformation.c,transformation.pyx和transformation.pyd。 I also read a little about Cython. 我还读了一些关于Cython的内容。

Firstly, all errors are of the same kind: 首先,所有错误都属于同一类:

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

The first error is raised here: 这里提出了第一个错误:

__pyx_t_3 = __pyx_v_self->mat;

The type of __pyx_t_3 is: __pyx_t_3的类型是:

__pyx_t_4kivy_8graphics_14transformation_matrix_t

It has this weird name because it was generated automatically from the transformation.pxd file: 它有这个奇怪的名称,因为它是从transformation.pxd文件自动生成的:

ctypedef double matrix_t[16]

So, type( __pyx_t_3 ) == type(matrix_t) == double *. 所以,输入( __pyx_t_3 )== type(matrix_t)== double *。

The type of __pyx_v_self is: __pyx_v_self的类型是:

struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *

Again, it was generated from transformation.pxd : 同样,它是从transformation.pxd生成的:

ctypedef double matrix_t[16]

cdef class Matrix:
    cdef matrix_t mat
    ...

Therefore, type( __pyx_v_self->mat ) == type(Matrix.mat) == type(matrix_t) == double * 因此,键入( __ pyx_v_self-> mat )== type(Matrix.mat)== type(matrix_t)== double *

As we can see, both sides of the assignment: 我们可以看到,任务的双方:

__pyx_t_3 = __pyx_v_self->mat;

are of (double *) type. 是(双*)类型。

Why is this error: 为什么会出现此错误:

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

being raised then? 被提出呢?

It looks like the compiler is not recognizing the type of matrix_t as a double *. 看起来编译器没有将matrix_t的类型识别为double *。

Just met the same error. 刚遇到同样的错误。 Using of Cython 0.17.1 helps me: 使用Cython 0.17.1可以帮助我:

sudo pip install Cython==0.17.1

If you want not just fix problem you can go in depth and check what was changed between this two versions. 如果您不想只修复问题,可以深入了解这两个版本之间的变化。 https://github.com/cython/cython/blob/master/CHANGES.rst#0172-2012-11-20 - here you can find related issues, but unfortunately I'm not a guru of C/Cython and quick glance to diff between master and 0.17.1 doesn't says me where is the problem, but if you wish you can investigate the problem by yourself. https://github.com/cython/cython/blob/master/CHANGES.rst#0172-2012-11-20 - 在这里你可以找到相关的问题,但不幸的是我不是C / Cython的大师和快速浏览在master和0.17.1之间进行区分并没有说明问题出在哪里,但如果你愿意,你可以自己调查问题。

I just had the same error as well. 我也有同样的错误。 I traced it down to a small example and sent an email to the Cython mailing list: https://groups.google.com/forum/?fromgroups=#!topic/cython-users/fSZgHqrlCOc 我将其追溯到一个小例子并发送电子邮件到Cython邮件列表: https ://groups.google.com/forum/?fromgroups = #!topic / cyce-users / fSZgHqrlCOc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM