软件安装是生信分析的基础,除了掌握基本的软件安装理论外之后 (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/mainconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/freeconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/rconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/proconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2conda 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 -Upip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
R包安装镜像
CRAN和Bioconductor的镜像
安装前现运行这几句话,或把这几句话放在~/.Rprofile或~/.Profile.site文件下 (Windows里面的路径是C:Program FilesRR-3.6.1etc)。
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")
自动安装包
# 安装BiocManagerif (!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 系统上的 Homebrewgit -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.gitgit -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.gitgit -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.gitgit -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_profilesource ~/.bash_profile
安装相应的gnu系列工具
#brew install bashbrew install coreutilsbrew install gawkbrew install gnu-sed
其它镜像
还有其它镜像,如Perl的CPAN,Linux操作系统安装包,Linux操作系统自带包管理工具(yum/apt)的源,Docker镜像等。
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!