Giter Club home page Giter Club logo

easyconnectedinchina's Introduction

汇总各种工具国内镜像源和设置镜像源的方法

【目前施工ing....】

欢迎大家一同参与XD~

汇总apt,pip,nodejs等各种工具国内镜像源和设置镜像源的方法

目录

目录
前言
正文
   pip
   npm
参考 / 感谢

正文

前言

过于国内特殊的网络环境,想比大家都经历过低速下载、404、丢失链接等等等等等问题。

这非常影响我们的工作效率,而百度一个一个找国内源的更换方法则非常麻烦,特此在这里进行一个小汇总。

如果大家遇到操作问题可以提交issue,也欢迎大家也pull request来贡献自己知道的源和方法~

pip

源地址

使用方法

方法一:临时使用

直接在pip后加-i后跟这次使用的源即可,例:

pip install web.py -i https://mirrors.aliyun.com/pypi/simple/

指令中的网址为上方的源地址。

如果出现带有trusted-host字样的报错,这是由源不为https协议导致的,使用:

pip install web.py -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

添加信任主机即可。

方法二:更改默认源

创建或修改配置文件(一般都是创建)

  • linux的文件在~/.pip/pip.conf,
  • vim ~/.pip/pip.conf
    
  • windows在%HOMEPATH%\pip\pip.ini

更改内容:

[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com

文件中的网址为上方的源地址。 刚刚下面的内容是http协议源的实例。需要添加信任。 保存退出即可。

方法三:python代码更改安装源

临时使用其他源安装软件包的python脚本如下:

#!/usr/bin/python
 
import os
 
package = raw_input("Please input the package which you want to install!\n")
command = "pip install %s -i https://mirrors.aliyun.com/pypi/simple/" % package
# http源的代码实例如下
# command = "pip install %s -i http://pypi.mirrors.ustc.edu.cn/simple --trusted-host pypi.mirrors.ustc.edu.cn" % package
os.system(command)

npm

源地址

使用方法

请注意,使用镜像库均不能publish,如需publish需要换回官方库

方法一:使用cnpm替代

安装cnpm:

npm install -g cnpm --registry=https://registry.npm.taobao.org

之后使用cnpm替代npm命令即可。支持除publish外所有命令:

cnpm install [name]

官方网址:http://npm.taobao.org/

方法二:临时替换

在执行npm命令时指定参数registry即可:

npm --registry https://registry.npm.taobao.org install express

方法三:持久使用

在命令行中执行:

npm config set registry https://registry.npm.taobao.org

或者~/.npmrc中添加

registry = https://registry.npm.taobao.org

(执行vim ~/.npmrc即可更改.npmrc内容)

查看更改是否生效:

npm config get registry

或者

npm info express

参考 / 感谢

easyconnectedinchina's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.