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

yipeiwu_com7年前Python基础

本文讲述了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程序设计有所帮助。

相关文章

numpy给array增加维度np.newaxis的实例

如下所示: a[:, np.newaxis] # 给a最外层中括号中的每一个元素加[] a[np.newaxis, :] # 给a最外层中括号中所有元素加[] 以上这篇numpy给...

使用python turtle画高达

使用python turtle画高达

我就废话不多说了,直接上代码吧! import turtle t=turtle.Turtle() turtle.Turtle().screen.delay(0) tleft=turt...

对Python 文件夹遍历和文件查找的实例讲解

实例如下所示: # -*- coding: utf-8 -*- #to find where use the table on xxxxx xxxxxx production en...

python time模块用法实例详解

本文详细讲述了python的内嵌time模块的用法。分享给大家供大家参考之用。具体分析如下:   一、简介 time模块提供各种操作时间的函数 说明:一般有两种表示时间的方式...

Python 实现域名解析为ip的方法

今天得了一批域名,需要把域名解析成ip 因为量比较大所以采用了多进程和队列的方式 from multiprocessing import Process,Queue,Pool imp...