• 【anaconda软件】Anaconda使用教程全攻略---解决conda安装不了包(十一)


    使用默认源有时候下载速度会很慢,所以找了一些国内的pip,conda源,下载的时候可以加速,使用起来也很简单。

    国内的pip源,如下:

    推荐使用清华源,支持包比较丰富

    conda操作

    一、单次使用

    # 单次使用
    conda install tensorflow -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

    二、配置conda源的地址

    # 配置清华conda镜像
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

    国内conda源:

    • 清华源
    1 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    2 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge 
    3 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
    4 
    5 # 设置搜索时显示通道地址
    6 conda config --set show_channel_urls yes
    • 中科大源
    1 conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
    2 conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
    3 conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
    4 conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
    5 conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
    6 conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
    7 
    8 conda config --set show_channel_urls yes

    三、win10配置conda源

    win10的conda配置清华源镜像时候的问题

     报错:
    HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/current_repodata.json>Elapsed: -

    解决措施:

    找到文件.condarc,按照如下内容修改:

    ssl_verify: true
    channels:
      - http://mirrors.ustc.edu.cn/anaconda/pkgs/main/win-64/
      - http://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/win-64/
      - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/
      - http://mirrors.ustc.edu.cn/anaconda/pkgs/main/win-64/
      - http://mirrors.ustc.edu.cn/anaconda/pkgs/free/win-64/
      - http://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/win-64/
      - http://mirrors.ustc.edu.cn/anaconda/cloud/msys2/win-64/
      - http://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/win-64/
      - http://mirrors.ustc.edu.cn/anaconda/cloud/menpo/win-64/
      - defaults
    show_channel_urls: true

    注意问题:

    1. 镜像末尾需要加  win-64/
    2. 把https改成http
    3. 如果channels 下面有 “- default” 的话需要删除它

    参考文章:

    1. win10的conda配置清华源镜像时候的问题

    2. ANACONDA 更新失败的解决办法

    3. Anaconda建立新的环境,出现CondaHTTPError: HTTP 000 CONNECTION FAILED for url ...... 解决过程

    pip操作

    一、单次使用

    使用方法很简单,直接 -i 加 url 即可!如下:

    # 单次使用
    pip install tensorflow -i http://pypi.douban.com/simple

    如果有如下报错:
           请使用命令:

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

    清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

    阿里云 http://mirrors.aliyun.com/pypi/simple/

    中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

    豆瓣(douban) http://pypi.douban.com/simple/

    中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

    二、pip配置镜像

     Windows

    直接在user目录下的用户名文件夹(电脑当前的名称)中创建一个pip目录,如:C:Usersxxpip,新建文件pip.ini,内容如下

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

    请注意:一定是在你个人用户文件夹下先建立pip文件夹,在建立pip.ini文件,不是直接把pip.ini文件放在C:Usersxx下

    # 配置清华PyPI镜像(如无法运行,将pip版本升级到>=10.0.0)
    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

     配置多个源

     1 #使用的时候将注释去掉
     2 [global]
     3 timeout = 10 # 超时
     4 index-url=http://pypi.douban.com/simple  # 豆瓣源
     5 extra-index-url=
     6     http://mirrors.aliyun.com/pypi/simple/  # 阿里云
     7     https://pypi.tuna.tsinghua.edu.cn/simple/  # 清华源
     8     http://pypi.mirrors.ustc.edu.cn/simple/   # 中科大源
     9 
    10 [install]
    11 trusted-host=
    12     pypi.douban.com
    13     mirrors.aliyun.com
    14     pypi.tuna.tsinghua.edu.cn
    15     pypi.mirrors.ustc.edu.cn

     下载链接:https://files.cnblogs.com/files/xf23554/pip%E6%BA%90.zip

    Linux(缺少)

    1.进入家目录的隐藏 .pip目录下

    cd ~/.pip

    2.创建并修改pip.conf

    [global]
    timeout = 10  # 超时 
    index-url = http://mirrors.aliyun.com/pypi/simple/  # 第一源
    index-index-url = http://pypi.douban.com/simple/  # 第二
    [install]
    trusted-host =
      mirrors.aliyun.com
      pypi.douban.com

    ps: 可以只指定一个源 ,只需删除第二源 及 trusted-host对应的

    参考文章:

    作者:小飞
    备注:本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。
    备注:部分图片下载来源于网络,如若有侵权,请联系本人予以删除,邮箱:2777418194@qq.com。
    本博客作为本人软件学习记录而用,不提供任何软件的下载链接,敬请谅解
    可关注本人微信公众号【软件开发部门】回复“资源”获取部分免费资源
  • 相关阅读:
    并发编程
    网络与WEB 编程
    包和模块
    元编程
    类和对象
    【算法题 14 LeetCode 147 链表的插入排序】
    剑指offer面试54题
    剑指offer 面试51题
    剑指offer 面试3题
    剑指offer 面试52题
  • 原文地址:https://www.cnblogs.com/xf23554/p/13828588.html
Copyright © 2020-2023  润新知