python换源
2024-09-04 15:35:50
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!")
- 把上面代码保存为.py文件
- 打开终端输入以下命令
python (你的文件名).py
完成!
最新文章
- Django models对象的select_related方法(减少查询次数)
- Oracle等待事件db file parallel read
- 测试的rtsp地址
- Keil: warning: A1581W: Added 2 bytes of padding at address
- 关于jQuery中.attr()和.prop()
- 性能测试平台效率优化的一次经验(python版)
- 【Owin 学习系列】1. 第一个 Owin 程序
- ElasticSearch和Kibana 5.X集群的安装
- 相似QQ对话框上下部分可拖动代码
- C程序员眼里的Python
- psvm中String [] args 理解
- (转)EF5+SQLserver2012迁移到EF6+mysql5.5.47
- 每天进步一点点-Java IO操作-Java Serializable(对象序列化)的理解和总结
- 使用STM32CubeMX生成待机开关功能
- MySQL库中表名忽略大小写设置的影响
- The end of the world
- vim-snipmate的c.snippets(2016.7.10)
- RMAN概述及其体系结构
- mount /dev/sr0 /media/cdrom you must specify the filesystem type
- 关于setTimeout的一个逻辑题