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
很不幸地,我再次遇到了連接錯誤的問題,咨詢了下別人建議我重新安裝一下,但之前所有的東西都要刪掉,還是算了,不過可以曲線救國,直接在鏡像上把包下載下來,手動安裝不就可以了
去鏡像上下載Index of /anaconda/cloud/bioconda/linux-64/ | 北京外國語大學開源軟件鏡像站 | BFSU Open Source Mirror isoseq3-3.8.2-h9ee0642_0.tar.bz2
然后cd ~/miniconda3/pkgs/
運行conda install --use-local isoseq3-3.8.2-h9ee0642_0.tar.bz2
實測可用!
3 conda遷移環境打包
conda install -c conda-forge conda-pack
conda pack -n env_name -o output.tar.gz
復制壓縮文件到新的電腦環境
進到conda的安裝目錄:~/miniconda/envs/
在該目錄下創建文件夾 mkdir jcvi
解壓conda環境:tar -xzvf output.tar.gz -C ~/miniconda/envs/jcvi/
使用conda env list
查看虛擬環境
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 env remove -p /usrdata/users/hwwang/miniconda3/envs/EDTAt
需要提示一下的是,如果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")
5 jupyterlab配置R
#在R軟件中,安裝包,
install.packages('IRkernel')#用于把R導入到jupyterlab
IRkernel::installspec()#默認是顯示的為名字為R,a kernel with the name “ir” and a display name of “R”
#如果后續需要導入其它的R環境,那可以使用下面的代碼,給它改個名字便于標記
IRkernel::installspec(name = 'ir33', displayname = 'R_4.3.1_singlecell')#可以修改展示的名字
以上,后續遇到問題再補充