美文网首页
conda的一些使用问题

conda的一些使用问题

作者: 郝永超M1racle | 来源:发表于2022-10-06 16:34 被阅读0次

conda用起来有些小问题,之前一直未能解决,将这些记录一下

1 往集群投递任务同时激活conda环境

看资料上说是改配置文件啥的,改完之后也没卵用,只需要在bash脚本里面加上绝对路径

#!/usr/bin/bash
source /usrdata/users/hwwang/miniconda3/bin/activate /usrdata/users/hwwang/miniconda3/envs/busco/

2 关于conda报HTTP连接错误的问题

问了下集群的管理员,其他使用者并没有遇到这种问题,说明并不是服务器网络的事,那就应该是conda的配置文件出现问题了,直接改一下配置文件,先做个备份 cp ~/.condarc ~/.condarc.bak
然后删除 .condarc 里的内容,把下面的内容复制到里面并保存

show_channel_urls: true
remote_read_timeout_secs: 1200.0
channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
ssl_verify: false

3 使用conda安装R语言及R包

创建并激活环境,我分别安装了两个R语言的环境,分别是R3.6.0以及R4.1.1,以R3.6.0为例:

conda env list # 查看已创建的conda环境列表
conda create -n r3.6  
conda activate r3.6 
conda install r-base=3.6.0 #安装R并指定版本
conda remove --name xxx --all #移除环境

需要提示一下的是,如果conda报找不到包的问题,是因为没有在配置文件里加上R的镜像,可以把 http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/ 加到你的 .condarc 文件里
然后就是安装了R包了
安装 ggpubr 的时候才体会到用conda有多香,这个包需要的依赖包贼多,安装过程挺长,我们集群如果在本地长时间运行任务会掉线,因此安装过程中断开了好多次,之后又把它提交到节点进行安装

#!/usr/bin/bash
source /usrdata/users/hwwang/miniconda3/bin/activate /usrdata/users/hwwang/miniconda3/envs/r3.6/
/usrdata/users/hwwang/miniconda3/envs/r3.6/bin/Rscript install.r

然后就是报错,类似这种 installation of package xxx had non-zero exit status

Warning messages:
1: In install.packages("ggpubr") :
  installation of package ‘stringi’ had non-zero exit status
2: In install.packages("ggpubr") :
  installation of package ‘stringr’ had non-zero exit status
3: In install.packages("ggpubr") :
  installation of package ‘knitr’ had non-zero exit status

实际上的报错有8条,这里放上几条展示一下,主要是stringr和stringi两个包安装的问题,查阅相关资料也未能解决
然后就想到用conda直接安装或许可以解决,清华大学开源软件镜像站 里面没有ggpubr包,但可以用它安装 stringr,运行 conda install r-stringr,安装完毕后,再安装 ggpubr ,显示安装成功,并可以使用

*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (ggpubr)

The downloaded source packages are in
    ‘/tmp/RtmpknjjaH/downloaded_packages’
> library(ggpubr)
Loading required package: ggplot2
> gg
gg_dep          ggboxplot       ggecdf          ggmaplot        ggplot          ggproto         ggscatterhist   ggtexttable     ggplot2::
ggadd           ggdensity       ggerrorplot     ggpaired        ggplot_add      ggproto_parent  ggstripchart    ggtitle         
ggarrange       ggdonutchart    ggexport        ggpar           ggplot_build    ggqqplot        ggsummarystats  ggviolin        
ggballoonplot   ggdotchart      gghistogram     ggparagraph     ggplot_gtable   ggsave          ggsummarytable  ggpubr::        
ggbarplot       ggdotplot       ggline          ggpie           ggplotGrob      ggscatter       ggtext          ggsignif::      

DONE!

4 记录R的配置文件,vi ~/.Rprofile

options(repos=structure(c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/")))
options(BioC_mirror="https://mirrors.tuna.tsinghua.edu.cn/bioconductor")
.libPaths("/usrdata/users/hwwang/hychao/R_libs")
options(help_type="html")

以上,后续遇到问题再补充

相关文章

网友评论

      本文标题:conda的一些使用问题

      本文链接:https://www.haomeiwen.com/subject/mhnmartx.html