萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mysql教程 >> _mysql.c:602: error: expected expression before ) token 解決辦法

_mysql.c:602: error: expected expression before ) token 解決辦法

本文章來給各位同學介紹關於_mysql.c:602: error: expected expression before ‘)’ token 解決辦法

在安裝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 --param=ssp-buffer-siz                                      e=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fPIC -Dversion_info=(1,2,4,'beta',4) -D__version__=1.                                      2.4b4 -I/usr/local/mysql/include/mysql -I/usr/include/python2.4 -c _mysql.c -o build/temp.linux-i686-2.4/_mysql.o -g -DUNIV_LINUX
_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了

copyright © 萬盛學電腦網 all rights reserved