Lepus监控-python基础模块安装

本文记录了在Python2.6.6环境下从下载到成功安装MySQLdb模块的全过程,包括解决编译错误及依赖缺失的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[root@goolen goolen]# python --version
Python 2.6.6
[root@goolen goolen]# wget http://www.mtop.cc/software/MySQLdb-python.zip 
--2015-03-26 17:45:54--  http://www.mtop.cc/software/MySQLdb-python.zip
正在解析主机 www.mtop.cc... 219.234.6.180
正在连接 www.mtop.cc|219.234.6.180|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:99967 (98K) [application/zip]
正在保存至: “MySQLdb-python.zip”

100%[=======================================================================================>] 99,967      35.8K/s   in 2.7s    

2015-03-26 17:46:07 (35.8 KB/s) - 已保存 “MySQLdb-python.zip” [99967/99967])

[root@goolen goolen]# unzip MySQLdb-python.zip 
Archive:  MySQLdb-python.zip
c8b2744ea2b1e4419b7e3d93928e92c95f366815
   creating: MySQLdb1-master/
  inflating: MySQLdb1-master/.gitignore  
  inflating: MySQLdb1-master/.travis.yml  
  inflating: MySQLdb1-master/GPL-2.0  
  inflating: MySQLdb1-master/HISTORY  
  inflating: MySQLdb1-master/INSTALL  
  inflating: MySQLdb1-master/MANIFEST.in  
   creating: MySQLdb1-master/MySQLdb/
  inflating: MySQLdb1-master/MySQLdb/__init__.py  
  inflating: MySQLdb1-master/MySQLdb/connections.py  
   creating: MySQLdb1-master/MySQLdb/constants/
  inflating: MySQLdb1-master/MySQLdb/constants/CLIENT.py  
  inflating: MySQLdb1-master/MySQLdb/constants/CR.py  
  inflating: MySQLdb1-master/MySQLdb/constants/ER.py  
  inflating: MySQLdb1-master/MySQLdb/constants/FIELD_TYPE.py  
  inflating: MySQLdb1-master/MySQLdb/constants/FLAG.py  
  inflating: MySQLdb1-master/MySQLdb/constants/REFRESH.py  
  inflating: MySQLdb1-master/MySQLdb/constants/__init__.py  
  inflating: MySQLdb1-master/MySQLdb/converters.py  
  inflating: MySQLdb1-master/MySQLdb/cursors.py  
  inflating: MySQLdb1-master/MySQLdb/release.py  
  inflating: MySQLdb1-master/MySQLdb/times.py  
  inflating: MySQLdb1-master/README.md  
  inflating: MySQLdb1-master/_mysql.c  
  inflating: MySQLdb1-master/_mysql_exceptions.py  
  inflating: MySQLdb1-master/distribute_setup.py  
   creating: MySQLdb1-master/doc/
  inflating: MySQLdb1-master/doc/FAQ.rst  
  inflating: MySQLdb1-master/doc/Makefile  
  inflating: MySQLdb1-master/doc/MySQLdb.constants.rst  
  inflating: MySQLdb1-master/doc/MySQLdb.rst  
  inflating: MySQLdb1-master/doc/_mysql.rst  
  inflating: MySQLdb1-master/doc/_mysql_exceptions.rst  
  inflating: MySQLdb1-master/doc/conf.py  
  inflating: MySQLdb1-master/doc/index.rst  
  inflating: MySQLdb1-master/doc/make.bat  
  inflating: MySQLdb1-master/doc/modules.rst  
  inflating: MySQLdb1-master/doc/user_guide.rst  
  inflating: MySQLdb1-master/metadata.cfg  
  inflating: MySQLdb1-master/pymemcompat.h  
  inflating: MySQLdb1-master/setup.cfg  
  inflating: MySQLdb1-master/setup.py  
  inflating: MySQLdb1-master/setup_common.py  
  inflating: MySQLdb1-master/setup_posix.py  
  inflating: MySQLdb1-master/setup_windows.py  
  inflating: MySQLdb1-master/site.cfg  
   creating: MySQLdb1-master/tests/
  inflating: MySQLdb1-master/tests/capabilities.py  
  inflating: MySQLdb1-master/tests/configdb.py  
  inflating: MySQLdb1-master/tests/dbapi20.py  
  inflating: MySQLdb1-master/tests/default.cnf  
  inflating: MySQLdb1-master/tests/test_MySQLdb_capabilities.py  
  inflating: MySQLdb1-master/tests/test_MySQLdb_dbapi20.py  
  inflating: MySQLdb1-master/tests/test_MySQLdb_nonstandard.py  
  inflating: MySQLdb1-master/tests/travis.cnf  

[root@goolen goolen]# cd MySQLdb1-master/
[root@goolen MySQLdb1-master]# which mysql_config
/tol/mysql/home/bin/mysql_config
[root@goolen MySQLdb1-master]# vim site.cfg 
mysql_config = /tol/mysql/home/bin/mysql_config

[root@goolen MySQLdb1-master]#  python setup.py build 
报错:
_mysql.c:2711: 错误:expected declaration specifiers or ‘...’ before ‘PyObject’
_mysql.c: 在函数‘_mysql_ResultObject_setattr’中:
_mysql.c:2713: 错误:‘v’未声明(在此函数内第一次使用)
_mysql.c:2714: 错误:‘PyExc_AttributeError’未声明(在此函数内第一次使用)
_mysql.c: 在文件层:
_mysql.c:2732: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_mysql_ConnectionObject_Type’
_mysql.c:2820: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_mysql_ResultObject_Type’
_mysql.c:2910: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_mysql_methods’
_mysql.c:2982: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_mysql.c:3030: 警告:返回类型默认为‘int’
_mysql.c: 在函数‘DL_EXPORT’中:
_mysql.c:3030: 错误:expected declaration specifiers before ‘init_mysql’
_mysql.c:3138: 错误:expected ‘{’ at end of input
error: command 'gcc' failed with exit status 1

[root@goolen MySQLdb1-master]# yum install -y python-devel mysql-devel zlib-devel openssl-devel
[root@goolen MySQLdb1-master]# python setup.py build

[root@goolen MySQLdb1-master]#  python setup.py install 


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23249684/viewspace-1474903/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/23249684/viewspace-1474903/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值