当前位置: 编程技术>python
python自动安装pip
来源: 互联网 发布时间:2014-10-04
本文导语: 如果是windows安装完成后,需要将'Python27Scripts'加入系统环境变量 代码如下:# coding=utf-8import osimport urllib2url='https://raw.github.com/pypa/pip/master/contrib/get-pip.py'print 'load begin,please waite'response=urllib2.urlopen(url)with open('./download.py','w') as f: f....
如果是windows安装完成后,需要将'Python27Scripts'加入系统环境变量
代码如下:
# coding=utf-8
import os
import urllib2
url='https://raw.github.com/pypa/pip/master/contrib/get-pip.py'
print 'load begin,please waite'
response=urllib2.urlopen(url)
with open('./download.py','w') as f:
f.write(response.read())
print 'load end'
import download
download.main()
print 'clear up'
filepath=['./download.py','./download.pyc']
try:
for path in filepath:
os.remove(path)
except :
pass
print 'insall pip success,please add 'Python27Scripts' to u enveronment path'