首頁  >  文章  >  後端開發  >  python自动安装pip

python自动安装pip

WBOY
WBOY原創
2016-06-16 08:44:28986瀏覽

如果是windows安装完成后,需要将'\Python27\Scripts\'加入系统环境变量

复制代码 代码如下:

# 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 \'\Python27\Scripts\' to u enveronment path'

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn