在安装mysql-python的时候遇到这么个问题:
- [root@centos01 MySQL-python-1.2.4b4]# python setup.py build
- running build
- running build_py
- copying MySQLdb/release.py -> build/lib.linux-i686-2.4/MySQLdb
- running build_ext
- building '_mysql' extension
- gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
- _mysql.c: In function ‘_mysql_ConnectionObject_Initialize’:
- _mysql.c:602: error: expected expression before ‘)’ token
- error: command 'gcc' failed with exit status 1
这里的源码有点问题,找到 _mysql.c 602行附近,找到下边的代码:
- if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- #ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
- "|ssssisOiiisssiOii:connect",
- #else
- "|ssssisOiiisssiOi:connect",
- #endif
- kwlist,
- &host, &user, &passwd, &db,
- &port, &unix_socket, &conv,
- &connect_timeout,
- &compress, &named_pipe,
- &init_command, &read_default_file,
- &read_default_group,
- &client_flag, &ssl,
- &local_infile,
- #ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
- &read_timeout
- #endif
- ))
-
- return -1;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- #ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
- "|ssssisOiiisssiOii:connect",
- #else
- "|ssssisOiiisssiOi:connect",
- #endif
- kwlist,
- &host, &user, &passwd, &db,
- &port, &unix_socket, &conv,
- &connect_timeout,
- &compress, &named_pipe,
- &init_command, &read_default_file,
- &read_default_group,
- &client_flag, &ssl,
- &local_infile
- #ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
- , &read_timeout
- #endif
- ))
-
- return -1;
再重新执行 python setup.py build 就OK了. |