npm 修改源 pip 修改源

本文详细介绍如何修改npm和pip的数据源,以提高在中国地区的安装速度。包括将npm源更改为淘宝镜像,以及pip源更改为阿里云、中国科技大学等国内镜像,并提供了常见错误的解决方案。

npm修改源
由于不可说原因,npm install时,速度总是不尽如人意,解决办法是修改npm的数据源
npm config set registry https://registry.npm.taobao.org
1
修改后可以通过这个进行测试

npm config get registry

 

 

pip-修改为国内镜像源

 

pip 常用命令

pip install ./downloads/SomePackage-1.0.4.tar.gz 
pip install http://my.package.repo/SomePackage-1.0.4.zip
pip search "query"   ##查询package的具体名称
pip uninstall package-name  ##卸载
pip install SomePackage==1.0.4  ##指定版本的安装
pip install --upgrade SomePackage  ##package 版本升级

pip-修改国内镜像源

mkdir ~/.pip 
vim ~/.pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com

注意事项:

  1. http://mirrors.aliyun.com/pypi/simple/中的simple目录必须有。
  2. --no-cache-dir重新下载安装包,而不是使用缓存包。
  3. trusted-host = mirrors.aliyun.com一定要加上这行,否则会报错。
  4. pip国内镜像源。

    阿里云 http://mirrors.aliyun.com/pypi/simple/
    中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
    豆瓣 http://pypi.douban.com/simple
    Python官方 https://pypi.python.org/simple/
    v2ex http://pypi.v2ex.com/simple/
    中国科学院 http://pypi.mirrors.opencas.cn/simple/
    清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

报错汇总

报错内容

pip install mysql-python
Collecting mysql-python
  The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host pypi.douban.com'.
  Could not find a version that satisfies the requirement mysql-python (from versions: )
No matching distribution found for mysql-python

解决办法

编辑 vim .pip/pip.conf

[install]
trusted-host = mirrors.aliyun.com

转载于:https://www.cnblogs.com/wzbk/p/10308190.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值