13

我想在 CentOs 上运行一个 django 项目。我尝试通过 easy_install 和 pip 安装 mysql-python,但我都遇到了错误。我用谷歌搜索了这个问题并找到了一些建议,但没有一个对我有帮助。

错误是:

_mysql.c:29:20: error: Python.h: No such file or directory
_mysql.c:40:26: error: structmember.h: No such file or directory
_mysql.c:74: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:75: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:76: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:77: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:78: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:79: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:80: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:81: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:82: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:83: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:84: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:87: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
_mysql.c:97: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_mysql_ConnectionObject_Type’
_mysql.c:100: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
_mysql.c:108: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_mysql_ResultObject_Type’
_mysql.c:127: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:261: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:361: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:379: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:402: error: expected declaration specifiers or ‘...’ before ‘PyObject’
_mysql.c:403: error: expected declaration specifiers or ‘...’ before ‘PyObject’
_mysql.c: In function ‘_mysql_ResultObject_Initialize’:
_mysql.c:405: error: ‘NULL’ undeclared (first use in this function)
_mysql.c:405: error: (Each undeclared identifier is reported only once
_mysql.c:405: error: for each function it appears in.)
_mysql.c:407: warning: initialization from incompatible pointer type
_mysql.c:409: error: ‘PyObject’ undeclared (first use in this function)
_mysql.c:409: error: ‘conv’ undeclared (first use in this function)
_mysql.c:409: error: invalid operands to binary * (have ‘char **’ and ‘char **’)
_mysql.c:409: warning: statement with no effect
_mysql.c:413: warning: implicit declaration of function ‘PyArg_ParseTupleAndKeywords’
_mysql.c:413: error: ‘args’ undeclared (first use in this function)
_mysql.c:413: error: ‘kwargs’ undeclared (first use in this function)
_mysql.c:417: warning: implicit declaration of function ‘PyDict_New’
_mysql.c:421: warning: implicit declaration of function ‘Py_INCREF’
_mysql.c:423: error: ‘_mysql_ResultObject’ has no member named ‘conn’
_mysql.c:423: error: expected expression before ‘)’ token
_mysql.c:423: error: invalid operands to binary * (have ‘char **’ and ‘char **’)
_mysql.c:423: warning: statement with no effect
_mysql.c:425: error: ‘_mysql_ResultObject’ has no member named ‘use’
_mysql.c:425: warning: statement with no effect
_mysql.c:426: error: ‘Py_BEGIN_ALLOW_THREADS’ undeclared (first use in this function)
_mysql.c:426: warning: statement with no effect
_mysql.c:428: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:428: warning: passing argument 1 of ‘mysql_use_result’ from incompatible pointer type
/usr/include/mysql/mysql.h:401: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:430: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:430: warning: passing argument 1 of ‘mysql_store_result’ from incompatible pointer type
/usr/include/mysql/mysql.h:400: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:431: error: ‘_mysql_ResultObject’ has no member named ‘result’
_mysql.c:431: warning: statement with no effect
_mysql.c:432: error: ‘Py_END_ALLOW_THREADS’ undeclared (first use in this function)
_mysql.c:432: warning: statement with no effect
_mysql.c:434: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:434: warning: passing argument 1 of ‘mysql_field_count’ from incompatible pointer type
/usr/include/mysql/mysql.h:368: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:435: warning: implicit declaration of function ‘_mysql_Exception’
_mysql.c:438: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:438: warning: implicit declaration of function ‘PyTuple_New’
_mysql.c:438: warning: statement with no effect
_mysql.c:439: warning: implicit declaration of function ‘Py_DECREF’
_mysql.c:443: error: ‘_mysql_ResultObject’ has no member named ‘nfields’
_mysql.c:443: warning: statement with no effect
_mysql.c:444: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:450: error: ‘tmp’ undeclared (first use in this function)
_mysql.c:450: error: invalid operands to binary * (have ‘char **’ and ‘char **’)
_mysql.c:450: error: ‘fun’ undeclared (first use in this function)
_mysql.c:450: warning: left-hand operand of comma expression has no effect
_mysql.c:450: warning: statement with no effect
_mysql.c:451: warning: implicit declaration of function ‘PyInt_FromLong’
_mysql.c:451: warning: statement with no effect
_mysql.c:456: warning: implicit declaration of function ‘PyObject_GetItem’
_mysql.c:456: warning: statement with no effect
_mysql.c:459: warning: implicit declaration of function ‘PyErr_Occurred’
_mysql.c:460: warning: implicit declaration of function ‘PyErr_ExceptionMatches’
_mysql.c:460: error: ‘PyExc_KeyError’ undeclared (first use in this function)
_mysql.c:464: warning: implicit declaration of function ‘PyErr_Clear’
_mysql.c:466: error: ‘Py_None’ undeclared (first use in this function)
_mysql.c:466: warning: statement with no effect
_mysql.c:469: warning: implicit declaration of function ‘PySequence_Check’
_mysql.c:470: warning: implicit declaration of function ‘PySequence_Size’
_mysql.c:471: error: ‘fun2’ undeclared (first use in this function)
_mysql.c:471: error: invalid operands to binary * (have ‘char **’ and ‘char **’)
_mysql.c:471: warning: statement with no effect
_mysql.c:473: error: ‘t’ undeclared (first use in this function)
_mysql.c:473: error: invalid operands to binary * (have ‘char **’ and ‘char **’)
_mysql.c:473: warning: implicit declaration of function ‘PySequence_GetItem’
_mysql.c:473: warning: statement with no effect
_mysql.c:479: warning: implicit declaration of function ‘PyTuple_Check’
_mysql.c:479: warning: implicit declaration of function ‘PyTuple_GET_SIZE’
_mysql.c:481: error: ‘pmask’ undeclared (first use in this function)
_mysql.c:481: error: invalid operands to binary * (have ‘char **’ and ‘char **’)
_mysql.c:481: warning: statement with no effect
_mysql.c:482: warning: implicit declaration of function ‘PyTuple_GET_ITEM’
_mysql.c:482: warning: statement with no effect
_mysql.c:483: warning: statement with no effect
_mysql.c:484: warning: implicit declaration of function ‘PyInt_Check’
_mysql.c:485: warning: implicit declaration of function ‘PyInt_AS_LONG’
_mysql.c:495: warning: statement with no effect
_mysql.c:504: warning: statement with no effect
_mysql.c:507: warning: statement with no effect
_mysql.c:509: warning: implicit declaration of function ‘PyTuple_SET_ITEM’
_mysql.c:509: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c: In function ‘_mysql_ResultObject_clear’:
_mysql.c:535: warning: implicit declaration of function ‘Py_XDECREF’
_mysql.c:535: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:536: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:536: error: ‘NULL’ undeclared (first use in this function)
_mysql.c:536: warning: statement with no effect
_mysql.c:537: error: ‘_mysql_ResultObject’ has no member named ‘conn’
_mysql.c:538: error: ‘_mysql_ResultObject’ has no member named ‘conn’
_mysql.c:538: warning: statement with no effect
_mysql.c: At top level:
_mysql.c:545: error: expected declaration specifiers or ‘...’ before ‘PyObject’
_mysql.c:546: error: expected declaration specifiers or ‘...’ before ‘PyObject’
_mysql.c: In function ‘_mysql_ConnectionObject_Initialize’:
_mysql.c:548: error: ‘NULL’ undeclared (first use in this function)
_mysql.c:548: warning: initialization from incompatible pointer type
_mysql.c:549: error: ‘PyObject’ undeclared (first use in this function)
_mysql.c:549: error: ‘conv’ undeclared (first use in this function)
_mysql.c:549: error: invalid operands to binary * (have ‘char **’ and ‘char **’)
_mysql.c:549: warning: statement with no effect
_mysql.c:550: error: ‘ssl’ undeclared (first use in this function)
_mysql.c:550: error: invalid operands to binary * (have ‘char **’ and ‘char **’)
_mysql.c:550: warning: statement with no effect
_mysql.c:552: warning: initialization from incompatible pointer type
_mysql.c:552: warning: initialization from incompatible pointer type
_mysql.c:552: warning: initialization from incompatible pointer type
_mysql.c:553: warning: initialization from incompatible pointer type
_mysql.c:553: warning: initialization from incompatible pointer type
_mysql.c:555: warning: initialization from incompatible pointer type
_mysql.c:555: warning: initialization from incompatible pointer type
_mysql.c:555: warning: initialization from incompatible pointer type
_mysql.c:556: warning: initialization from incompatible pointer type
_mysql.c:556: warning: initialization from incompatible pointer type
_mysql.c:569: error: initializer element is not constant
_mysql.c:569: error: (near initialization for ‘kwlist[17]’)
_mysql.c:575: warning: initialization from incompatible pointer type
_mysql.c:576: warning: initialization from incompatible pointer type
_mysql.c:577: warning: initialization from incompatible pointer type
_mysql.c:579: error: ‘_mysql_ConnectionObject’ has no member named ‘converter’
_mysql.c:579: warning: statement with no effect
_mysql.c:580: error: ‘_mysql_ConnectionObject’ has no member named ‘open’
_mysql.c:580: warning: statement with no effect
_mysql.c:583: error: ‘args’ undeclared (first use in this function)
_mysql.c:583: error: ‘kwargs’ undeclared (first use in this function)
_mysql.c:616: error: ‘value’ undeclared (first use in this function)
_mysql.c:616: error: invalid operands to binary * (have ‘char **’ and ‘char **’)
_mysql.c:616: warning: statement with no effect
_mysql.c:617: warning: implicit declaration of function ‘PyMapping_GetItemString’
_mysql.c:617: warning: statement with no effect
_mysql.c:617: warning: implicit declaration of function ‘PyString_AsString’
_mysql.c:617: warning: assignment makes pointer from integer without a cast
_mysql.c:618: warning: statement with no effect
_mysql.c:618: warning: assignment makes pointer from integer without a cast
_mysql.c:619: warning: statement with no effect
_mysql.c:619: warning: assignment makes pointer from integer without a cast
_mysql.c:620: warning: statement with no effect
_mysql.c:620: warning: assignment makes pointer from integer without a cast
_mysql.c:621: warning: statement with no effect
_mysql.c:621: warning: assignment makes pointer from integer without a cast
_mysql.c:629: error: ‘Py_BEGIN_ALLOW_THREADS’ undeclared (first use in this function)
_mysql.c:629: warning: statement with no effect
_mysql.c:630: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:630: warning: passing argument 1 of ‘mysql_init’ from incompatible pointer type
/usr/include/mysql/mysql.h:380: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:633: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:634: warning: passing argument 1 of ‘mysql_options’ from incompatible pointer type
/usr/include/mysql/mysql.h:445: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:639: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:640: warning: passing argument 1 of ‘mysql_options’ from incompatible pointer type
/usr/include/mysql/mysql.h:445: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:644: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:644: warning: passing argument 1 of ‘mysql_options’ from incompatible pointer type
/usr/include/mysql/mysql.h:445: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:648: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:648: warning: passing argument 1 of ‘mysql_options’ from incompatible pointer type
/usr/include/mysql/mysql.h:445: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:649: warning: comparison of distinct pointer types lacks a cast
_mysql.c:650: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:650: warning: passing argument 1 of ‘mysql_options’ from incompatible pointer type
/usr/include/mysql/mysql.h:445: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:651: warning: comparison of distinct pointer types lacks a cast
_mysql.c:652: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:652: warning: passing argument 1 of ‘mysql_options’ from incompatible pointer type
/usr/include/mysql/mysql.h:445: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:653: warning: comparison of distinct pointer types lacks a cast
_mysql.c:654: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:654: warning: passing argument 1 of ‘mysql_options’ from incompatible pointer type
/usr/include/mysql/mysql.h:445: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:657: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:657: warning: passing argument 1 of ‘mysql_options’ from incompatible pointer type
/usr/include/mysql/mysql.h:445: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:661: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:662: warning: passing argument 1 of ‘mysql_ssl_set’ from incompatible pointer type
/usr/include/mysql/mysql.h:381: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:665: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:666: warning: passing argument 1 of ‘mysql_real_connect’ from incompatible pointer type
/usr/include/mysql/mysql.h:387: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:668: error: ‘Py_END_ALLOW_THREADS’ undeclared (first use in this function)
_mysql.c:668: warning: statement with no effect
_mysql.c:677: warning: statement with no effect
_mysql.c:683: error: ‘_mysql_ConnectionObject’ has no member named ‘converter’
_mysql.c:683: warning: statement with no effect
_mysql.c:691: error: ‘_mysql_ConnectionObject’ has no member named ‘open’
_mysql.c:691: warning: statement with no effect
_mysql.c: At top level:
_mysql.c:749: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c: In function ‘_mysql_ConnectionObject_clear’:
_mysql.c:781: error: ‘_mysql_ConnectionObject’ has no member named ‘converter’
_mysql.c:782: error: ‘_mysql_ConnectionObject’ has no member named ‘converter’
_mysql.c:782: error: ‘NULL’ undeclared (first use in this function)
_mysql.c:782: warning: statement with no effect
_mysql.c: At top level:
_mysql.c:789: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:817: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:833: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:851: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:870: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:896: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:918: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:950: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:976: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1003: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1022: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1039: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1055: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1077: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1124: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1167: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1169: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1203: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1233: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1267: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1299: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1335: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1359: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1389: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1414: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1453: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1492: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1497: error: expected declaration specifiers or ‘...’ before ‘PyObject’
_mysql.c:1500: error: expected declaration specifiers or ‘...’ before ‘_PYFUNC’
_mysql.c: In function ‘_mysql__fetch_row’:
_mysql.c:1506: error: ‘PyObject’ undeclared (first use in this function)
_mysql.c:1506: error: ‘v’ undeclared (first use in this function)
_mysql.c:1506: error: invalid operands to binary * (have ‘char **’ and ‘char **’)
_mysql.c:1506: warning: statement with no effect
_mysql.c:1507: error: ‘_mysql_ResultObject’ has no member named ‘use’
_mysql.c:1508: error: ‘_mysql_ResultObject’ has no member named ‘result’
_mysql.c:1508: warning: passing argument 1 of ‘mysql_fetch_row’ from incompatible pointer type
/usr/include/mysql/mysql.h:454: note: expected ‘struct MYSQL_RES *’ but argument is of type ‘char **’
_mysql.c:1510: error: ‘Py_BEGIN_ALLOW_THREADS’ undeclared (first use in this function)
_mysql.c:1510: warning: statement with no effect
_mysql.c:1511: error: ‘_mysql_ResultObject’ has no member named ‘result’
_mysql.c:1511: warning: passing argument 1 of ‘mysql_fetch_row’ from incompatible pointer type
/usr/include/mysql/mysql.h:454: note: expected ‘struct MYSQL_RES *’ but argument is of type ‘char **’
_mysql.c:1512: error: ‘Py_END_ALLOW_THREADS’ undeclared (first use in this function)
_mysql.c:1512: warning: statement with no effect
_mysql.c:1514: error: ‘_mysql_ResultObject’ has no member named ‘conn’
_mysql.c:1514: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:1514: warning: passing argument 1 of ‘mysql_errno’ from incompatible pointer type
/usr/include/mysql/mysql.h:371: note: expected ‘struct MYSQL *’ but argument is of type ‘char * (*)[1]’
_mysql.c:1515: error: ‘_mysql_ResultObject’ has no member named ‘conn’
_mysql.c:1519: warning: implicit declaration of function ‘_PyTuple_Resize’
_mysql.c:1519: error: ‘r’ undeclared (first use in this function)
_mysql.c:1522: warning: implicit declaration of function ‘convert_row’
_mysql.c:1522: warning: statement with no effect
_mysql.c: At top level:
_mysql.c:1540: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1619: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1647: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1673: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1713: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1755: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1774: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1793: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1808: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1828: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1867: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1885: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1908: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1925: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1941: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1970: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:1993: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:2023: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:2045: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:2072: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:2098: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:2139: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:2159: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c: In function ‘_mysql_ConnectionObject_dealloc’:
_mysql.c:2193: error: ‘PyObject’ undeclared (first use in this function)
_mysql.c:2193: error: ‘o’ undeclared (first use in this function)
_mysql.c:2193: error: invalid operands to binary * (have ‘char **’ and ‘char **’)
_mysql.c:2193: warning: statement with no effect
_mysql.c:2196: error: ‘_mysql_ConnectionObject’ has no member named ‘open’
_mysql.c:2197: warning: implicit declaration of function ‘_mysql_ConnectionObject_close’
_mysql.c:2197: error: ‘NULL’ undeclared (first use in this function)
_mysql.c:2197: warning: statement with no effect
_mysql.c:2200: warning: implicit declaration of function ‘PyMem_Free’
_mysql.c: At top level:
_mysql.c:2203: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:2224: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:2239: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:2261: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c: In function ‘_mysql_ResultObject_dealloc’:
_mysql.c:2283: error: ‘_mysql_ResultObject’ has no member named ‘result’
_mysql.c:2283: warning: passing argument 1 of ‘mysql_free_result’ from incompatible pointer type
/usr/include/mysql/mysql.h:447: note: expected ‘struct MYSQL_RES *’ but argument is of type ‘char **’
_mysql.c: At top level:
_mysql.c:2288: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:2302: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_mysql_ConnectionObject_methods’
_mysql.c:2517: error: array type has incomplete element type
_mysql.c:2518: error: ‘T_INT’ undeclared here (not in a function)
_mysql.c:2518: warning: implicit declaration of function ‘offsetof’
_mysql.c:2518: error: expected expression before ‘_mysql_ConnectionObject’
_mysql.c:2518: error: ‘READONLY’ undeclared here (not in a function)
_mysql.c:2525: error: ‘T_OBJECT’ undeclared here (not in a function)
_mysql.c:2525: error: expected expression before ‘_mysql_ConnectionObject’
_mysql.c:2532: error: ‘T_UINT’ undeclared here (not in a function)
_mysql.c:2532: error: expected expression before ‘_mysql_ConnectionObject’
_mysql.c:2539: error: expected expression before ‘_mysql_ConnectionObject’
_mysql.c:2546: error: expected expression before ‘_mysql_ConnectionObject’
_mysql.c:2553: error: ‘NULL’ undeclared here (not in a function)
_mysql.c:2556: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_mysql_ResultObject_methods’
_mysql.c:2608: error: array type has incomplete element type
_mysql.c:2609: error: expected expression before ‘_mysql_ResultObject’
_mysql.c:2619: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:2649: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:2681: error: expected declaration specifiers or ‘...’ before ‘PyObject’
_mysql.c: In function ‘_mysql_ConnectionObject_setattr’:
_mysql.c:2683: error: ‘v’ undeclared (first use in this function)
_mysql.c:2684: warning: implicit declaration of function ‘PyErr_SetString’
_mysql.c:2684: error: ‘PyExc_AttributeError’ undeclared (first use in this function)
_mysql.c:2689: warning: implicit declaration of function ‘PyMember_Set’
_mysql.c: At top level:
_mysql.c:2706: error: expected declaration specifiers or ‘...’ before ‘PyObject’
_mysql.c: In function ‘_mysql_ResultObject_setattr’:
_mysql.c:2708: error: ‘v’ undeclared (first use in this function)
_mysql.c:2709: error: ‘PyExc_AttributeError’ undeclared (first use in this function)
_mysql.c: At top level:
_mysql.c:2727: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_mysql_ConnectionObject_Type’
_mysql.c:2815: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_mysql_ResultObject_Type’
_mysql.c:2905: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_mysql_methods’
_mysql.c:2977: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:3022: warning: return type defaults to ‘int’
_mysql.c: In function ‘DL_EXPORT’:
_mysql.c:3022: error: expected declaration specifiers before ‘init_mysql’
_mysql.c:3130: error: expected ‘{’ at end of input
error: Setup script exited with error: command 'gcc' failed with exit status 1
4

6 回答 6

37

我认为您需要先安装python开发库:

yum install python-devel
于 2012-10-24T07:01:30.190 回答
34

只是提到其他可能也会在这里结束的人,

安装 python-devel 后,我遇到了同样的错误,但是缺少mysql_config.h我在安装 mysql-devel 时解决了这个错误

$ yum install mysql-devel.x86_64 

希望这可以帮助

于 2013-01-29T14:42:32.143 回答
4

我找到了一个类似的解决方案:

yum -y install python-devel mysql-devel
于 2014-02-07T08:08:56.867 回答
1

我有同样的错误,但出于不同的原因(pypy + virtualenv)。

这是我得到的错误:

Installing collected packages: mysql-python
  Found existing installation: MySQL-python 1.2.4
    Uninstalling MySQL-python:
      Successfully uninstalled MySQL-python
  Running setup.py install for mysql-python
    building '_mysql' extension
    cc -O2 -fPIC -Wimplicit -Dversion_info=(1,2,4,'final',1) -D__version__=1.2.4 -I/usr/include/mysql -I/mnt/hgfs/Work/devel-centos/include -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -DUNIV_LINUX -DUNIV_LINUX

_mysql.c:29:20: error: Python.h: No such file or directory

请注意include_diris -I/mnt/hgfs/Work/devel-centos/include(that's $VIRTUAL_ENV/include),并且该位置没有任何内容。

我的设置:

  • CentOS 6.4
  • pypy 2.0.2已安装(即 python 2.7.3)
  • virtualenv 1.10.1安装并创建了我的环境

    virtualenv -p /usr/bin/pypy devel-centos

  • 已安装 python 2.6

    yum install python-devel没有为我解决问题;它创建了/usr/lib64/python2.6/在该pip install mysql-python步骤中未使用的。

解决问题的2种方法:

  1. 将正确的 python 头文件符号链接到您的 virtualenv:

    yum install pypy-devel  # which creates /usr/lib64/pypy-2.0.2/
    ln -s /usr/lib64/pypy-2.0.2/include $VIRTUAL_ENV/include
    
  2. 或将setup.cfg文件更改为mysql-python

    pip install --no-install mysql-python
    

    然后编辑$VIRTUAL_ENV/build/mysql-python/setup.cfg

    [build_ext]
    include_dirs = /usr/lib64/pypy-2.0.2/include
    

    并继续安装。

    pip install --no-download mysql-python
    
于 2013-10-15T23:16:46.760 回答
1

解决这个问题的另一种方法是yum install python27-MySQL-python.x86_64.

于 2013-11-28T14:42:50.630 回答
0

同样的问题;Python.h not found,发现没有安装python-virtualenv;

yum -y install python-virtualenv
于 2016-01-21T12:57:43.860 回答