Centos为一般用户安装MySQLdb

来源:互联网 发布:咫尺网络小程序 编辑:程序博客网 时间:2024/05/18 04:00

环境与背景

OS: CentOS 6.6
Python: 2.6.6
Pip: 7.1.0 (Pip安装请参考https://pip.pypa.io/en/stable/installing.html)

安装过程

pip install MySQL-python --user

一条命令即可解决,--user选项是为当前用户,也是普通用户安装MySQLdb.

安装问题点

  • 缺少python-dev的包:
    错误表现为,

    pymemcompat.h:10:20: error: Python.h: No such file or directory
    解决方法为,

    yum install python-devel

  • 缺少MySQL的开发包:
    错误表现为,

    _mysql.c:36:23: error: my_config.h: No such file or directory
    _mysql.c:38:19: error: mysql.h: No such file or directory
    _mysql.c:39:26: error: mysqld_error.h: No such file or directory
    _mysql.c:40:20: error: errmsg.h: No such file or directory
    解决方法为,

    yum install  mysql-devel 

成功验证

输入命令:

python -c 'import MySQLdb'

如果没有任何输出,表示MySQLdb已安装完成.

参考

安装MySQL易错点

0 0
原创粉丝点击