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

完成!

python换源的更多相关文章

  1. Python用pip安装第三方库时换源下载

    pip默认是从Python官网下载第三方库,从国外下载当然不如从国内下载来得快 豆瓣:https://pypi.doubanio.com/simple 还有其它源,阿里云等等,一个就够用了 用pip安 ...

  2. python pip 升级 或者换源

    1. 临时换源python -m pip install --upgrade pip -i https://pypi.douban.com/simple pip国内的一些镜像   阿里云  https ...

  3. Python解释器换源

    Python解释器换源 """ 1.采用国内源,加速下载模块的速度 2.常用pip源: -- 豆瓣:https://pypi.douban.com/simple -- 阿 ...

  4. python第三方库的安装pip的使用与换源(解决pip下载速度慢)

    python和其他语言一样,也有大量的第三方库 在安装python时默认都会安装pip,安装了pip后 在cmd.exe下可以运行pip 安装库 pip install 库的名字 换源 因为PyPi地 ...

  5. Python中安装框架如何换源以及升级

    想安装tornado框架,但总是有奇怪错误,如下: 如果按照默认的下载源,就会死活不成功,出现 Traceback (most recent call last): File "e:\pyt ...

  6. Python pip换源

    前言 哈喽呀,小伙伴们,晚上好呀,今天要给大家带来点什么呐,我们就来说说python的pip换源吧,这个换源,相对来说,还是比较重要的,能少生好几次气的,哈哈哈 为什么要换源 我们搞python的,肯 ...

  7. python虚拟环境 + 批量pip + 换源

    python虚拟环境 + 批量pip + 换源 虚拟环境 曾经我是一个小白,不管运行什么项目都用一个环境,后来项目多了,有的是Django1.11的有的是Django2的,有的项目只能在3.6上运行, ...

  8. Anaconda换源及常用命令

    推荐一篇文章:http://www.cnblogs.com/IT-LearnHall/p/9486029.html 另外,记录几个自己遇到的问题 首先是换源.无论是安装包还是安装后更新python包, ...

  9. PyCharm使用指南及更改Python pip源为国内豆瓣

    PyCharm基本使用 1.在PyCharm下为python项目配置python本地解释器 setting-->Project:pycharm workspace-->Project In ...

随机推荐

  1. 洛谷P1177 【模板】快速排序

    https://www.luogu.org/problem/P1177 #include<bits/stdc++.h> using namespace std; int n; multis ...

  2. turtleh海龟库

    Turtle海龟库 导入 import turtle turtle.setup(width,height,startx,starty) -setup():设置窗体的位置和大小 相对于桌面的起点的坐标以 ...

  3. 其他-使用 ProcessExplorer 定位 win10 系统资源占用

    1. 概述 使用 ProcessExplorer 2. 环境 os win10 3. 背景 偶然在论坛上看到了一个工具 ProcessExplorer 作用是 定位当前桌面窗口 对应的 进程 我没有这 ...

  4. oracle 启动

    Oracle数据库启动过程及状态详解(nomount.mount和open) 先来简要了解一下Oracle数据库体系架构以便于后面深入理解,Oracle Server主要由实例(instance)和数 ...

  5. 删除空目录命令 - rmdir

    (1) 命令名称:rmdir (2) 英文原意:remove empty directories (3) 命令所在路径:/bin/rmdir (4) 执行权限:所有用户 (5) 功能描述:删除空目录( ...

  6. Hibernate:Hibernate缓存策略详解

    一:为什么使用Hibernate缓存: Hibernate是一个持久层框架,经常访问物理数据库. 为了降低应用程序访问物理数据库的频次,从而提高应用程序的性能. 缓存内的数据是对物理数据源的复制,应用 ...

  7. SpringBoot开发快速入门

    SpringBoot开发快速入门 目录 一.Spring Boot 入门 1.Spring Boot 简介 2.微服务 3.环境准备 1.maven设置: 2.IDEA设置 4.Spring Boot ...

  8. Unity 坐标系转换

    在Unity中我们通常会用到以下几个坐标系下的点: 世界坐标系:World Space 简单来讲,我们通过 transform.position | transform.rotation 获取得到的位 ...

  9. npm解决node-sass安装失败

    npm装包一直都很成功,直到我遇见了node-sass这个包 我一直报这样的错误 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-sas ...

  10. kali2018.4 下载地址

    https://www.linuxidc.com/Linux/2018-10/155088.htm