文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

anaconda python更换清华源

2023-01-31 07:11

关注

前言

在使用anaconda python环境过程中你会发现使用conda下载包的速度非常的慢,因为使用的是国外的服务器,所以这里要设置为国内的镜像。使用下面的配置命令即可:

添加Anaconda的TUNA镜像

conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'      //TUNA的help中镜像地址加有引号,需要去掉# 
conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/'
conda config --setshow_channel_urls yes      //设置搜索时显示通道地址

添加后

(base) C:\Users\aikera>conda config --show channels
channels:
  - 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/'
  - 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
  - defaults
  - conda-forge

还有简单粗暴地方法:直接修改conda的配置,一般在当前用户路径下,比如C:\Users\Administrator.condarc
.condarc具体内容如下:

channels:
  - 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/'
  - 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
  - defaults
  - conda-forge

验证

conda config --show
(base) C:\Users\aikera>conda config --show
add_anaconda_token: True
add_pip_as_python_dependency: True
aggressive_update_packages:
  - ca-certificates
  - certifi
  - openssl
allow_non_channel_urls: False
allow_softlinks: False
always_copy: False
always_softlink: False
always_yes: None
anaconda_upload: None
auto_update_conda: True
changeps1: True
channel_alias: https://conda.anaconda.org
channel_priority: True
channels:
  - 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/'
  - 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
  - defaults
  - conda-forge
client_ssl_cert: None
client_ssl_cert_key: None
clobber: False
create_default_packages: []
custom_channels:
  pkgs/r: https://repo.anaconda.com
  pkgs/msys2: https://repo.anaconda.com
  pkgs/main: https://repo.anaconda.com
  pkgs/pro: https://repo.anaconda.com
  pkgs/free: https://repo.anaconda.com
custom_multichannels:
  local: []
  defaults: ["https://repo.anaconda.com/pkgs/main", "https://repo.anaconda.com/pkgs/free", "https://repo.anaconda.com/pkgs/r", "https://repo.anaconda.com/pkgs/pro", "https://repo.anaconda.com/pkgs/msys2"]
default_channels:
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/free
  - https://repo.anaconda.com/pkgs/r
  - https://repo.anaconda.com/pkgs/pro
  - https://repo.anaconda.com/pkgs/msys2
disallowed_packages: []
download_only: False
envs_dirs:
  - D:\ProgramData\Anaconda2\envs
  - C:\Users\aikera\AppData\Local\conda\conda\envs
  - C:\Users\aikera\.conda\envs

测试:

安装numpy试试:

(base) C:\Users\aikera>conda install numpy
Solving environment: /
WARNING: The remote server could not find the noarch directory for the
requested channel with url: https://conda.anaconda.org/'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/'

It is possible you have given conda an invalid channel. Please double-check
your conda configuration using `conda config --show`.

If the requested url is in fact a valid conda channel, please request that the
channel administrator create `noarch/repodata.json` and associated
`noarch/repodata.json.bz2` files, even if `noarch/repodata.json` is empty.
$ mkdir noarch
$ echo '{}' > noarch/repodata.json
$ bzip2 -k noarch/repodata.json
/
WARNING: The remote server could not find the noarch directory for the
requested channel with url: https://conda.anaconda.org/'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'

It is possible you have given conda an invalid channel. Please double-check
your conda configuration using `conda config --show`.

If the requested url is in fact a valid conda channel, please request that the
channel administrator create `noarch/repodata.json` and associated
`noarch/repodata.json.bz2` files, even if `noarch/repodata.json` is empty.
$ mkdir noarch
$ echo '{}' > noarch/repodata.json
$ bzip2 -k noarch/repodata.json
done

## Package Plan ##

  environment location: D:\ProgramData\Anaconda2

  added / updated specs:
    - numpy

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    numpy-1.15.0               |   py27h911edcf_0          36 KB  defaults
    numpy-base-1.15.0          |   py27hfef472a_0         3.8 MB  defaults
    llvmlite-0.24.0            |   py27hc56fc5f_0         9.2 MB  defaults
    numba-0.39.0               |   py27h39f3610_0         2.4 MB  defaults
    mkl_fft-1.0.4              |   py27h31cbb53_1         121 KB  defaults
    mkl-2018.0.3               |                1       178.1 MB  defaults
    conda-4.5.10               |           py27_0         1.0 MB  defaults
    blas-1.0                   |              mkl           6 KB  defaults
    ------------------------------------------------------------
                                           Total:       194.7 MB

The following NEW packages will be INSTALLED:

    blas:       1.0-mkl               defaults
    mkl_fft:    1.0.4-py27h31cbb53_1  defaults
    numpy-base: 1.15.0-py27hfef472a_0 defaults

The following packages will be UPDATED:

    conda:      4.4.11-py27_0         defaults --> 4.5.10-py27_0         defaults
    llvmlite:   0.20.0-py27_0         defaults --> 0.24.0-py27hc56fc5f_0 defaults
    mkl:        2018.0.0-h36b65af_4   defaults --> 2018.0.3-1            defaults
    numba:      0.35.0-np113py27_10   defaults --> 0.39.0-py27h39f3610_0 defaults
    numpy:      1.13.3-py27h9ac254c_0 defaults --> 1.15.0-py27h911edcf_0 defaults

Proceed ([y]/n)? y

Downloading and Extracting Packages
numpy 1.15.0: ################################################################################################# | 100%
numpy-base 1.15.0: ############################################################################################ | 100%
llvmlite 0.24.0: ############################################################################################## | 100%
numba 0.39.0: ################################################################################################# | 100%
mkl_fft 1.0.4: ################################################################################################ | 100%
mkl 2018.0.3: ################################################################################################# | 100%
conda 4.5.10: ################################################################################################# | 100%
blas 1.0: ##################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     807人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     351人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     314人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     433人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     221人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-后端开发
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯