Python下的常用下载安装工具pip的安装方法
1、pip下载安装
1.1pip下载
#wget"https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb"--no-check-certificate #wget"https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb"--no-check-certificate
1.2pip安装
#tar-xzvfpip-1.5.4.tar.gz #cdpip-1.5.4 #pythonsetup.pyinstall #tar-xzvfpip-1.5.4.tar.gz #cdpip-1.5.4 #pythonsetup.pyinstall
2.pip使用详解
2.1pip安装包
#pipinstallSomePackage
[...] SuccessfullyinstalledSomePackage
#pipinstallSomePackage
[...] SuccessfullyinstalledSomePackage
2.2pip查看已安装的包
#pipshow--filesSomePackage
Name:SomePackage Version:1.0 Location:/my/env/lib/pythonx.x/site-packages Files: ../somepackage/__init__.py [...]
#pipshow--filesSomePackage
Name:SomePackage Version:1.0 Location:/my/env/lib/pythonx.x/site-packages Files: ../somepackage/__init__.py [...]
2.3pip检查哪些包需要更新
#piplist--outdated
SomePackage(Current:1.0Latest:2.0)
#piplist--outdated
SomePackage(Current:1.0Latest:2.0)
2.4pip升级包
#pipinstall--upgradeSomePackage
[...] Foundexistinginstallation:SomePackage1.0 UninstallingSomePackage: SuccessfullyuninstalledSomePackage Runningsetup.pyinstallforSomePackage SuccessfullyinstalledSomePackage
#pipinstall--upgradeSomePackage
[...] Foundexistinginstallation:SomePackage1.0 UninstallingSomePackage: SuccessfullyuninstalledSomePackage Runningsetup.pyinstallforSomePackage SuccessfullyinstalledSomePackage
2.5pip卸载包
$pipuninstallSomePackage
UninstallingSomePackage: /my/env/lib/pythonx.x/site-packages/somepackage Proceed(y/n)?y SuccessfullyuninstalledSomePackage
$pipuninstallSomePackage
UninstallingSomePackage: /my/env/lib/pythonx.x/site-packages/somepackage Proceed(y/n)?y SuccessfullyuninstalledSomePackage
3.使用pip国内源
python使用pip安装模块很方便,可是在国内官方源总是会间歇性的连接不上,其实python在国内也是有安装源的,比如豆瓣,下面是使用方法.
文件路径
linux
~/.pip/pip.conf
文件内容
[global] index-url=http://pypi.douban.com/simple trusted-host=pypi.douban.com
或者使用-i指令:
easy_install-ihttp://pypi.douban.com/simple/saltTesting pipinstall-ihttp://pypi.douban.com/simple/saltTesting
pip安装:
1.下载get-pip.py并运行
https://bootstrap.pypa.io/get-pip.py
切换到get-pip.py所在目录下:pythonget-pip.py
2.添加环境变量:C:\Python27\Scripts;
C:\Users\Administrator>python--version
Python2.7.8
C:\Users\Administrator>pip--version
pip1.5.6fromC:\Python27\lib\site-packages(python2.7)
C:\Users\Administrator>添加环境变量C:\Python27;C:\Python27\Scripts;
'添加环境变量'不是内部或外部命令,也不是可运行的程序
或批处理文件。
C:\Users\Administrator>pipinstallselenium
Requirementalreadysatisfied(use--upgradetoupgrade):seleniuminc:\python2
7\lib\site-packages
Cleaningup...
C:\Users\Administrator>python
Python2.7.8(default,Jun302014,16:03:49)[MSCv.150032bit(Intel)]onwin
32
Type"help","copyright","credits"or"license"formoreinformation.
>>>importselenium
>>>