欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

python自动安装pip

程序员文章站 2023-11-11 20:10:40
如果是windows安装完成后,需要将'\python27\scripts\'加入系统环境变量复制代码 代码如下:# coding=utf-8import osimport...

如果是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'