首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python 2.6.6安装MySQL-

python 2.6.6安装MySQL-

作者头像
py3study
发布2020-01-06 10:30:39
8860
发布2020-01-06 10:30:39
举报
文章被收录于专栏:python3python3

1.下载安装setuptools

[root@localhost opt]#wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c8.tar.gz

[root@localhost opt]#tar xzf setuptools-0.6c8.tar.gz

[root@localhost setuptools-0.6c8]# python setup.py build

[root@localhost setuptools-0.6c8]# python setup.py install

2.下载安装MySQL-python

[root@localhost opt]# wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download

[root@localhost opt]# cd MySQL-python-1.2.3/

[root@localhost 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[0].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

[root@localhost MySQL-python-1.2.3]# python setup.py install

3.测试

[root@localhost MySQL-python-1.2.3]# python

Python 2.6.6 (r266:84292, May 24 2013, 21:09:02)

[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] 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

解决方法:

[root@localhost MySQL-python-1.2.3]# cd ..

[root@localhost opt]# python

Python 2.6.6 (r266:84292, May 24 2013, 21:09:02)

[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import MySQLdb

>>>

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-09-20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档