色婆ijqwj 发表于 2018-8-3 13:17:48

python 2.6.6安装MySQL-python模块

  1.下载安装setuptools
  #wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c8.tar.gz
  #tar xzf setuptools-0.6c8.tar.gz
  # python setup.py build
  # python setup.py install
  2.下载安装MySQL-python
  # wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download
  # cd MySQL-python-1.2.3/
  # python setup.py build
  报错信息:...
  _mysql.c:2091: error: ‘r’ undeclared (first use in this function)
  _mysql.c:2091: error: ‘_mysql_ResultObject’ has no member named ‘result’
  _mysql.c:2092: error: ‘_mysql_ResultObject’ has no member named ‘result’
  _mysql.c: In function ‘_mysql_ResultObject_dealloc’:
  _mysql.c:2100: warning: implicit declaration of function ‘mysql_free_result’
  _mysql.c:2100: error: ‘_mysql_ResultObject’ has no member named ‘result’
  _mysql.c: At top level:
  _mysql.c:2331: error: ‘_mysql_ConnectionObject’ has no member named ‘open’
  _mysql.c:2338: error: ‘_mysql_ConnectionObject’ has no member named ‘converter’
  _mysql.c:2345: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
  _mysql.c:2352: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
  _mysql.c:2359: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
  _mysql.c:2422: error: ‘_mysql_ResultObject’ has no member named ‘converter’
  _mysql.c:2422: error: initializer element is not constant
  _mysql.c:2422: error: (near initialization for ‘_mysql_ResultObject_memberlist.offset’)
  _mysql.c: In function ‘_mysql_ConnectionObject_getattr’:
  _mysql.c:2444: error: ‘_mysql_ConnectionObject’ has no member named ‘open’
  error: command 'gcc' failed with exit status 1
  解决方法:yum -y install mysql-devel libxml2 libxml2-dev libxslt* zlib gcc openssl
  # python setup.py install
  3.测试
  # python
  Python 2.6.6 (r266:84292, May 24 2013, 21:09:02)
   on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import MySQLdb
  /usr/local/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/local/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg/_mysql.pyc, but /opt/MySQL-python-1.2.3 is being added to sys.path
  解决方法:
  # cd ..
  # python
  Python 2.6.6 (r266:84292, May 24 2013, 21:09:02)
   on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import MySQLdb
  >>>
页: [1]
查看完整版本: python 2.6.6安装MySQL-python模块