pip源的更新

引用自:PyPI使用国内源

# coding: utf-8

import platform
import os os_type = platform.system()
if "Linux" == os_type:
fileDirPath = "%s/.pip" % os.path.expanduser('~')
filePath = "%s/pip.conf" % fileDirPath
if not os.path.isdir(fileDirPath):
os.mkdir(fileDirPath)
fo = open(filePath, "w")
fo.write(
"[global]\nindex-url=https://pypi.tuna.tsinghua.edu.cn/simple/\n[install]\ntrusted-host=pypi.tuna.tsinghua.edu.cn\n")
fo.close()
elif "Windows" == os_type:
fileDirPath = "%s\\pip" % os.path.expanduser('~')
filePath = "%s\\pip.ini" % fileDirPath
if not os.path.isdir(fileDirPath):
os.mkdir(fileDirPath)
fo = open(filePath, "w")
fo.write(
"[global]\nindex-url=https://pypi.tuna.tsinghua.edu.cn/simple/\n[install]\ntrusted-host=pypi.tuna.tsinghua.edu.cn\n")
fo.close()
else:
exit("Your platform is unknow!")
  1. 把上面代码保存为.py文件
  2. 打开终端输入以下命令

python (你的文件名).py

完成!

最新文章

  1. Django models对象的select_related方法(减少查询次数)
  2. Oracle等待事件db file parallel read
  3. 测试的rtsp地址
  4. Keil: warning: A1581W: Added 2 bytes of padding at address
  5. 关于jQuery中.attr()和.prop()
  6. 性能测试平台效率优化的一次经验(python版)
  7. 【Owin 学习系列】1. 第一个 Owin 程序
  8. ElasticSearch和Kibana 5.X集群的安装
  9. 相似QQ对话框上下部分可拖动代码
  10. C程序员眼里的Python
  11. psvm中String [] args 理解
  12. (转)EF5+SQLserver2012迁移到EF6+mysql5.5.47
  13. 每天进步一点点-Java IO操作-Java Serializable(对象序列化)的理解和总结
  14. 使用STM32CubeMX生成待机开关功能
  15. MySQL库中表名忽略大小写设置的影响
  16. The end of the world
  17. vim-snipmate的c.snippets(2016.7.10)
  18. RMAN概述及其体系结构
  19. mount /dev/sr0 /media/cdrom you must specify the filesystem type
  20. 关于setTimeout的一个逻辑题

热门文章

  1. 如何把U盘的两个盘或者多个盘合成一个
  2. ORA-00917: missing comma
  3. CentOS 7防火墙快速开放端口配置方法
  4. 用OpenCV读取摄像头
  5. python之路之课后作业
  6. python后续学习
  7. totensor方法和normalize方法 数值映射和归一化
  8. js/jquery加入的select value显示不正确问题
  9. 消息中间件MQTT
  10. python SMTP发邮件