Home  >  Article  >  Backend Development  >  python安装mysql-python简明笔记(ubuntu环境)

python安装mysql-python简明笔记(ubuntu环境)

WBOY
WBOYOriginal
2016-07-06 13:29:531045browse

本文讲述了python安装mysql-python的方法。分享给大家供大家参考,具体如下:

ubuntu 系统下进行的操作

首先安装了pip工具

sudo apt-get install python-pip

然后使用

sudo pip install mysql-python

安装第三方库.但是此时报错

sh: mysql_config: not found
Traceback (most recent call last):
 File "setup.py", line 15, in <module>
  metadata, options = get_config()
 File "/home/zhxia/apps/source/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
  libs = mysql_config("libs_r")
 File "/home/zhxia/apps/source/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
  raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

原因是没有安装:libmysqlclient-dev

sudo apt-get install libmysqlclient-dev

继续安装 发现 还是报错

mysql.c:29:20: fatal error: Python.h: 没有那个文件或目录,找不到Python头文件,难道wheezy默认没有安装python开发包?

sudo dpkg -l | grep python-dev

果然没有,还真的需要安装:

sudo apt-get install python-dev

MySQL-python就可以编译通过了。

更多关于Python相关内容感兴趣的读者可查看本站专题:《Python图片操作技巧总结》、《Python数据结构与算法教程》、《Python Socket编程技巧总结》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》、《Python入门与进阶经典教程》及《Python文件与目录操作技巧汇总》

希望本文所述对大家Python程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn