pip & conda 更换国内源

284 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。

目录

  • pip 更换国内源

  • conda 更换国内源

pip 更换国内源

镜像地址:

阿里云 mirrors.aliyun.com/pypi/simple… 豆瓣pypi.douban.com/simple/ 清华大学 pypi.tuna.tsinghua.edu.cn/simple/ 中国科学技术大学 pypi.mirrors.ustc.edu.cn/simple/ 华中科技大学pypi.hustunique.com/

说明:

临时使用 pip后面加上-i参数,指定pip源 如:

pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple

永久修改: linux: 修改 ~/.pip/pip.conf (没有就创建一个), 内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

windows: 直接在user目录中创建一个pip目录,如:C:\Users\username\pip,新建文件pip.ini,内容如下

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

conda 更换国内源

conda常用命令汇总

  1. 添加清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
#设置搜索时显示通道地址
conda config --set show_channel_urls yes
  1. 添加中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
  1. 查看
#查看当前的 cofig 
conda config --show

#查看添加的镜像:
conda config --get channels
  1. 删除源
conda config --remove-key channels

conda创建环境时报错:NotWritableError: The current user does not have write permissions to a required path.

问题描述:conda创建环境时报错:NotWritableError: The current user does not have write permissions to a required path. path: /Users/的情况。

问题出现的主要原因:用户没有对anaconda3文件夹的读写权限,造成其原因可能是由于在安装anaconda时使用了管理员权限。

cd到anaconda文件夹所在位置,运行以下命令即可

sudo chown -R xxx anaconda3    #xxx为自己的用户名

如何在conda中降低Python版本

我们有时候在配置环境的时候会遇到版本不匹配的问题,不得不降低版本,下面是conda中降低Python版本的方法
conda install python==3.6

等号后面表示需要退回的版本号