如何用conda查看镜像源(软件安装不上可能是网速慢)

软件安装是生信分析的基础,除了掌握基本的软件安装理论外之后 (Linux - 命令运行监测和软件安装),就是去下载源码安装或使用包管理工具安装通常操作都没问题时,软件却怎么都装不上,这一般都是网络问题所以你需要一个能够快速访问的镜像,下载快还不容易断,今天小编就来说说关于如何用conda查看镜像源?下面更多详细答案一起来看看吧!

如何用conda查看镜像源(软件安装不上可能是网速慢)

如何用conda查看镜像源

软件安装是生信分析的基础,除了掌握基本的软件安装理论外之后 (Linux - 命令运行监测和软件安装),就是去下载源码安装或使用包管理工具安装。通常操作都没问题时,软件却怎么都装不上,这一般都是网络问题。所以你需要一个能够快速访问的镜像,下载快还不容易断。

国内的镜像比较全的有清华镜像 (https://mirrors.tuna.tsinghua.edu.cn)和阿里云镜像 (https://developer.aliyun.com/mirror/)。下面以清华镜像为例 (阿里云镜像没有conda),展示下其操作。

Conda镜像

Conda增加清华的镜像,运行下面的代码 (后添加的通道优先级更高)

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main 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/r conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/

或直接把下面文字拷贝到 ~/.condarc中 (越靠前的优先级越高)

channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/

Python包管理工具 pip镜像

可以每次安装时加-i参数 (或使用alias命令)。

注意,simple不能少, 是https而不是 http。

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

升级 pip 到最新的版本 (>=10.0.0) 后进行永久配置:

pip install pip -U pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

R包安装镜像

CRAN和Bioconductor的镜像

安装前现运行这几句话,或把这几句话放在~/.Rprofile或~/.Profile.site文件下 (Windows里面的路径是C:\Program Files\R\R-3.6.1\etc)。

local({r <- getOption("repos") r["CRAN"] <- "http://mirrors.tuna.tsinghua.edu.cn/CRAN/" options(repos=r)}) options(BioC_mirror="https://mirrors.tuna.tsinghua.edu.cn/bioconductor")

自动安装包

# 安装BiocManager if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") # 获取已安装包 a = rownames(installed.packages()) install_package <- c("RColorBrewer", "gplots", "agricolae","optparse") # 判断包是否存在,不存在则安装 for (i in install_package) { if (!i %in% a) BiocManager::install(i, update = F) }

如果是Github的包安装起来比较慢,可以考虑在码云(https://gitee.com/)注册个账户,把`Github`的库先克隆到码云 (点击几下就可以实现,码云的服务器访问Github还是很快的),然后再下载到本地安装即可。

HomeBrew

Mac下默认的不少Linux命令如awk, sed,cat等与Linux下使用方式有些差别,通常需要安装GNU系列的对应命令来统一代码操作。可以通过brew安装,但brew update过程默认是极其的慢,也需要改一下镜像。

安装Brew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

配置镜像

# brew 程序本身,Homebrew/Linuxbrew 相同 git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git # 索引的镜像 # 以下针对 mac OS 系统上的 Homebrew git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git # 更换后测试工作是否正常 brew update # 软件包的镜像 echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile

安装相应的gnu系列工具

#brew install bash brew install coreutils brew install gawk brew install gnu-sed

其它镜像

还有其它镜像,如Perl的CPAN,Linux操作系统安装包,Linux操作系统自带包管理工具(yum/apt)的源,Docker镜像等。

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页