在安装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 //Vevb.com
- "|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了.
新闻热点
疑难解答