安装MySQLdb for centos 7--小白教程
2016-06-30 11:55
441 查看
1.MySQLdb下载地址:
https://pypi.python.org/pypi/MySQL-python/1.2.5
2. unzip MySQL-python-1.2.5;
3. cd MySQL-python-1.2.5;
python setup.py install;
此时报错:
Traceback (most recent call last):
File "setup.py", line 17, in <module>
metadata, options = get_config()
File "/root/MySQL-python-1.2.5/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/root/MySQL-python-1.2.5/setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
原因是没有安装mysql-devel;
yum install mysql-devel;
4.重新运行python setup.py install;
此时报错:
unable to execute gcc: No such file or directory
error: command 'gcc' failed with exit status 1
安装gcc就可以了: yum install gcc;
5.再次运行python setup.py install;
fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
安装:yum install python-devel;
注意:有很多资料说要下载python-dev,说的是centos6,
centos7上是下载不来的;
6.运行
python setup.py install;
Processing dependencies for MySQL-python==1.2.5
Finished processing dependencies for MySQL-python==1.2.5
至此MySQLdb安装成功了。
https://pypi.python.org/pypi/MySQL-python/1.2.5
2. unzip MySQL-python-1.2.5;
3. cd MySQL-python-1.2.5;
python setup.py install;
此时报错:
Traceback (most recent call last):
File "setup.py", line 17, in <module>
metadata, options = get_config()
File "/root/MySQL-python-1.2.5/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/root/MySQL-python-1.2.5/setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
原因是没有安装mysql-devel;
yum install mysql-devel;
4.重新运行python setup.py install;
此时报错:
unable to execute gcc: No such file or directory
error: command 'gcc' failed with exit status 1
安装gcc就可以了: yum install gcc;
5.再次运行python setup.py install;
fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
安装:yum install python-devel;
注意:有很多资料说要下载python-dev,说的是centos6,
centos7上是下载不来的;
6.运行
python setup.py install;
Processing dependencies for MySQL-python==1.2.5
Finished processing dependencies for MySQL-python==1.2.5
至此MySQLdb安装成功了。
相关文章推荐
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- Python将excel导入到mysql中
- Python在CAM软件Genesis2000中的应用
- 使用Shiboken为C++和Qt库创建Python绑定
- FREEBASIC 编译可被python调用的dll函数示例
- Python 七步捉虫法