mysqldb下载:

http://sourceforge.net/projects/mysql-python/

https://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/

http://mysql-python.sourceforge.net/

setuptools 工具安装:

1.wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py     //下载:ez_setup.py 
2.python ez_setup.py --insecure 

产生文件:easy_install,setuptools-23.1.0-py2.7.egg

Installing easy_install script to /usr/local/bin
    Installing easy_install-2.7 script to /usr/local/bin

Installed /usr/local/lib/python2.7/site-packages/setuptools-23.1.0-py2.7.egg     //记录结果

[root@localhost ~]# which easy_install
    /usr/local/bin/easy_install

[root@localhost MySQL-python-1.2.3]# python setup.py install 

[root@localhost site-packages]# ll
总用量 772
drwxr-xr-x 17 root root 4096 Jun 28 03:58 django
drwxr-xr-x 2 root root 4096 Jun 28 03:58 Django-1.9.7.dist-info
-rw-r--r-- 1 root root 291 Jun 28 04:04 easy-install.pth
drwxr-xr-x 3 root root 4096 Jun 28 03:39 MySQLdb
-rw-r--r-- 1 root root 2352 Jun 28 03:39 _mysql_exceptions.py
-rw-r--r-- 1 root root 4303 Jun 28 03:39 _mysql_exceptions.pyc
-rw-r--r-- 1 root root 105453 Jun 28 04:51 MySQL_python-1.2.3-py2.7-linux-x86_64.egg
drwxr-xr-x 2 root root 4096 Jun 28 03:39 MySQL_python-1.2.5-py2.7.egg-info
-rwxr-xr-x 1 root root 148389 Jun 28 03:39 _mysql.so
drwxr-xr-x 4 root root 4096 Jun 28 03:33 pip-1.5.4-py2.7.egg
-rw-r--r-- 1 root root 119 Mar 20 17:49 README
-rw-r--r-- 1 root root 472857 Jun 28 03:06 setuptools-23.1.0-py2.7.egg
-rw-r--r-- 1 root root 30 Jun 28 03:06 setuptools.pth
[root@localhost site-packages]# pwd
/usr/local/lib/python2.7/site-packages
pip, easy_install使用方式

安装使用easy_install
安装:
$ wget -q http://peak.telecommunity.com/dist/ez_setup.py
$ python ./ez_setup.py
使用:
$ easy_install PackageName #安装套件
$ easy_install -U PackageName #更新套件
$ easy_install -m PackageName #卸载套件
$ easy_install --showhelp #显示说明 安装使用pip
安装:
$ easy_install -U setuptools #更新setuptools版本(重要),pip依赖于setuptools
$ easy_install pip
使用:
$ pip install PackageName #安装套件
$ pip install -U PackageName #更新套件
$ pip uninstall PackageName #卸载套件
$ pip search PackageName #搜索套件
$ pip help #显示说明
#-*- encoding: gb2312 -*-
import os, sys, string
import MySQLdb # 连接数据库 
try:
conn = MySQLdb.connect(host='localhost',user='root',passwd='xxxx',db='test1')
except Exception, e:
print e
sys.exit() # 获取cursor对象来进行操作 cursor = conn.cursor()
# 创建表
sql = "create table if not exists test1(name varchar(128) primary key, age int(4))"
cursor.execute(sql)
# 插入数据
sql = "insert into test1(name, age) values ('%s', %d)" % ("zhaowei", 23)
try:
cursor.execute(sql)
except Exception, e:
print e sql = "insert into test1(name, age) values ('%s', %d)" % ("张三", 21)
try:
cursor.execute(sql)
except Exception, e:
print e
# 插入多条 sql = "insert into test1(name, age) values (%s, %s)"
val = (("李四", 24), ("王五", 25), ("洪六", 26))
try:
cursor.executemany(sql, val)
except Exception, e:
print e #查询出数据
sql = "select * from test1"
cursor.execute(sql)
alldata = cursor.fetchall()
# 如果有数据返回,就循环输出, alldata是有个二维的列表
if alldata:
for rec in alldata:
print rec[0], rec[1] cursor.close() conn.close()

手动安装 mysqldb 与[ pip easy_install]的更多相关文章

  1. 如何在使用MAMP环境下安装MySQLdb

    我的电脑上没有安装XAMPP,而是安装了MAMP PRO,其实两者都差不多,都是PHP+MySQL+Apache的集成环境,只是MAMP的GUI界面更华丽一些,但是也更复杂一些. 好了不说这些,说说问 ...

  2. windows7环境下使用pip安装MySQLdb for python3.7

    1.首先,需要确定你已经安装了pip.在Python2.7的安装包中,easy_install.py和pip都是默认安装的.可以在Python的安装目录先确认,如果\Python37\Scripts里 ...

  3. windows7环境下使用pip安装MySQLdb

    1.首先,需要确定你已经安装了pip.在Python2.7的安装包中,easy_install.py和pip都是默认安装的.可以在Python的安装目录先确认,如果\Python27\Scripts里 ...

  4. Centos7 pip 安装MySQLdb(mysql-python)出错

    租了个阿里云的Centos7的ECS,需要使用pip安装MySQLdb模块.也就是mysql-python模块. 但是遇到问题 Collecting mysql-python Downloading ...

  5. 手动安装pip

    apt-get instal pip  成功之后,有根据pip的提示,进行了升级,升级之后,pip就出问题了 为了解决上面问题,手动安装pip,依次执行下面命令 1 2 3 4 5 [root@min ...

  6. 在 Mac 中安装 MySQLdb (Python mysql )

    安装环境:OS X操作系统,Python 2.7.3. MySQLdb其实包含在MySQL-python包中,因此无论下载还是在pip中search,都应该是搜寻MySQL-python. 以下将说明 ...

  7. Mac下XAMPP环境中安装MySQLdb

    环境: Mac OS X. Mac下安装MySQLdb模块着实多了些步骤. 用easy_install或者pip安装时有两大问题,"mysql_config not found"和 ...

  8. python 安装setuptools、pip《转》

    https://www.jianshu.com/p/e9ab614cad9b 安装setuptools 下载setuptools源码setuptools-25.2.0.tar.gz 地址:https: ...

  9. PyCharm虚拟环(Project Interpreter)手动安装第三方包图解教程

    PyCharm虚拟环(Project Interpreter)手动安装第三方包图解教程 an鑫_wolfxin2010 关注 2018.03.13 21:58* 字数 313 阅读 3782评论 1喜 ...

随机推荐

  1. String的一些细节

    String 常量池问题 (1) 字符串常量的"+"号连接,在编译期字符串常量的值就确定下来, 拿"a" + 1来说,编译器优化后在class中就已经是a1. ...

  2. Uva 10294 Arif in Dhaka (First Love Part 2)

    Description 现有一颗含\(N\)个珠子的项链,每个珠子有\(t\)种不同的染色.现求在旋转置换下有多少种本质不同的项链,在旋转和翻转置换下有多少种本质不同的项链.\(N < 51,t ...

  3. in an effort to

    What does "in an effort" to mean? I personally consider in an effort to a stock phrase1. T ...

  4. IIS支持net.tcp

    绑定 高级设置  http和net.tcp用逗号分隔 //擦擦擦,见鬼了,下面的是tcp.net导致我找了好久,都找不出这个错误 //一定要注意,不要写错了. 否则会收到提示:找不到具有绑定 NetT ...

  5. java 图片文件格式转换(多页tif转jpg 、jpg转tif)

    package util; import java.awt.image.RenderedImage; import java.awt.image.renderable.ParameterBlock; ...

  6. fopen\fread\fwrite\fscanf\fprintf\fseek\feof\rewind\fgets\fputc等系列函数使用总结

    转载自:http://blog.csdn.net/xidianzhimeng/article/details/23541289 1 fopen 函数原型:FILE * fopen(const char ...

  7. 《Linear Algebra and Its Applications》-chaper1-线性方程组- 线性变换

    两个定理非常的简单显然,似乎是在证明矩阵代数中的基本运算律.但是它为后面用“线性变换”理解矩阵-向量积Ax奠定了理论基础. 结合之前我们讨论过的矩阵和向量的积Ax的性质,下面我们就可以引入线性变换了. ...

  8. 如何在 Linux 终端下创建新的文件系统/分区

    在 Linux 中创建分区或新的文件系统通常意味着一件事:安装 Gnome Parted 分区编辑器(GParted).对于大多数 Linux 用户而言,这是唯一的办法.不过,你是否考虑过在终端创建这 ...

  9. POJ 3922 A simple stone game

    题目: E - A simple stone game Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d &am ...

  10. 腾讯sdk配置

    android-mirror.bugly.qq.com