一、Python包管理工具
Python包管理工具,可以很方便的安装第三方模块
1. setuptools
下载地址:https://pypi.python.org/pypi/setuptools/
setuptools-24.0.3.tar.gz的下载地址:
https://pypi.python.org/packages/84/24/610d8bb87219ed6d0928018b7b35ac6f6f6ef27a71ed6a2d0cfb68200f65/setuptools-24.0.3.tar.gz
1)Ubuntu 安装:sudo apt-get install python-setuptools
2)CentOS 安装:
tar zxvf setuptools-24.0.3.tar.gz
cd setuptools-24.0.3
python setup.py build
python setup.py install
3)windows安装:先下载ez_setup.py,命令行进入其目录,执行
python setup.py build
python setup.py install
目前还未了解其用法,mysqldb对其有依赖关系。
2. pip(建议使用pip管理插件包)
下载地址:https://pypi.python.org/pypi/pip/ 下载pip-8.1.2.tar.gz
1)Ubuntu 安装:sudo apt-get install python-pip
2)windows安装:下载工具包,命令行进入其目录,
注:windows python2.7自带版本较低,初次使用时会提示升级。
D:\Python27\Scripts>pip install --upgrade pip
You are using pip version 7.0.1, however version 8.1.2 is available.
You should consider upgrading via the ‘pip install --upgrade pip‘ command.
Collecting pip
Downloading pip-8.1.2-py2.py3-none-any.whl (1.2MB)
100% |████████████████████████████████| 1.2MB 48kB/s
Installing collected packages: pip
Found existing installation: pip 7.0.1
Uninstalling pip-7.0.1:
Successfully uninstalled pip-7.0.1
Failed to write executable - trying to use .deleteme logic
Successfully installed pip-8.1.2
D:\Python27\Scripts>
3)CentOS6.x 下安装
tar zxvf pip-8.1.2.tar.gz
cd pip-8.1.2
python setup.py build
python setup.py install
使用示例:
# pip -h
Usage:
pip <command> [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion
help Show help for commands.
例如:安装redis包
# pip install redis
# pip list
MySQL-python (1.2.3)
pip (8.1.2)
redis (2.10.5)
setuptools (24.0.3)
二、常用第三方Python插件安装
1. MySQLdb的安装与使用
(1) windows版本MySQLdb安装
http://www.codegood.com/downloads
下载MySQL-python-1.2.3.win-amd64-py2.7.ext直接安装即可。
python测试模块安装后测试。
import MySQLdb
(2) CentOS6.x下安装安装MySQLdb模块
注:安装MySQLdb模块过程中会提示需要安装setuptools,所以需要先安装setuptools
[[email protected] MySQL-python-1.2.3]# python setup.py build
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from setuptools import setup, Extension
ImportError: No module named setuptools
MySQL-python-1.2.3.tar.gz的下载地址:
http://jaist.dl.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz
或这里下载:
http://sourceforge.net/projects/mysql-python/
https://pypi.python.org/pypi/MySQL-python/1.2.4
setuptools-24.0.3.tar.gz的下载地址:
https://pypi.python.org/packages/84/24/610d8bb87219ed6d0928018b7b35ac6f6f6ef27a71ed6a2d0cfb68200f65/setuptools-24.0.3.tar.gz
安装过程如下:
tar xvf MySQL-python-1.2.3.tar.gz
cd MySQL-python-1.2.3
python setup.py build
python setup.py install
(3) pip方式安装
用 pip 安装 MySQLdb 也就是一句命令,需要事先安装pip。
pip install MySQL-python
2. linux 下安装 paramiko模块
paramiko是一个用于做远程控制的模块,使用该模块可以对远程服务器进行命令或文件操作。
pycrypto,由于 paramiko 模块内部依赖pycrypto,所以先下载安装pycrypto
# 下载安装 pycrypto
wget http://files.cnblogs.com/files/wupeiqi/pycrypto-2.6.1.tar.gz
tar -xvf pycrypto-2.6.1.tar.gz
cd pycrypto-2.6.1
python setup.py build
python setup.py install
# 进入python环境,导入Crypto检查是否安装成功
# 下载安装 paramiko
wget http://files.cnblogs.com/files/wupeiqi/paramiko-1.10.1.tar.gz
tar -xvf paramiko-1.10.1.tar.gz
cd paramiko-1.10.1
python setup.py build
python setup.py install
# 进入python环境,导入paramiko检查是否安装成功
3. linux下安装连接cx_oracle库,用于python连接oracle数据库
博客链接:
http://koumm.blog.51cto.com/703525/1436501
...