当前位置: 首页 > news >正文

Ubuntu中使用miniconda安装R和R包devtools

安装devtools环境包 

sudo apt-get install gfortran -y
sudo apt-get install build-essential -y
sudo apt-get install libxt-dev -y
sudo apt-get install libcurl4-openssl-dev -y
sudo apt-get install libxml++2.6-dev -y
sudo apt-get install libssl-dev -y
sudo apt-get install libxml2 -y
sudo apt-get install libxml2-dev -y
sudo apt-get install libgit2-dev -y
sudo apt-get install libfontconfig1-dev -y
sudo apt-get install libharfbuzz-dev libfribidi-dev -y
sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev -y
sudo apt-get install libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev -y

下载安装miniconda

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh #给下载下来的安装文件添加执行权限
sudo bash Miniconda3-latest-Linux-x86_64.sh

切换到root用户,配置环境,vi ~/.bashrc 在最后添加下面内容

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/root/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; theneval "$__conda_setup"
elseif [ -f "/root/miniconda3/etc/profile.d/conda.sh" ]; then. "/root/miniconda3/etc/profile.d/conda.sh"elseexport PATH="/root/miniconda3/bin:$PATH"fi
fi
unset __conda_setup
# <<< conda initialize <<<

运行source ~/.bashrc  使配置生效

进入conda环境

source ~/.bashrc
conda

可通过修改conda源来提供下载速度。 

cat .condarc

channels:- https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/- https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/- https://mirrors.ustc.edu.cn/anaconda/pkgs/r/show_channel_urls: truedefault_channels:- https://mirrors.ustc.edu.cn/anaconda/pkgs/main- https://mirrors.ustc.edu.cn/anaconda/pkgs/r- https://mirrors.ustc.edu.cn/anaconda/pkgs/msys2custom_channels:conda-forge: https://mirrors.ustc.edu.cn/anaconda/cloudmsys2: https://mirrors.ustc.edu.cn/anaconda/cloudbioconda: https://mirrors.ustc.edu.cn/anaconda/cloudmenpo: https://mirrors.ustc.edu.cn/anaconda/cloudpytorch: https://mirrors.ustc.edu.cn/anaconda/cloudsimpleitk: https://mirrors.ustc.edu.cn/anaconda/cloud
更新conda
conda update -n base conda

安装mamba 

conda install mamba -n base -c conda-forge

因为Conda官方从2022年3月就提出比Conda更快解决方案-Libmamba。为了解决conda生态系统内部与增长相关的挑战,conda维护人员与合作伙伴Anaconda、Quansight和QuantStack一起在2022年12月引入了基于Mamba项目的新conda依赖项求解器。QuantStack,开发 mamba 和 libmamba;Quansight,将 libmamba 集成到 conda 中;和Anaconda,开发 conda 并管理整体工作。mamba是 conda 包管理器的 C++ 重新实现。

更新到Conda 23.10.0的时候,它们自动默认使用conda-libmamba-solver插件。 

官网解释:Conda 23.10.0: libmamba is now the default solver | conda.org

但我觉得还是要配置下求解器: 

安装并设置新的求解器

conda install -n base conda-libmamba-solver
conda config --set solver libmamba

创建R4.4环境

conda create -n r4.4# To activate this environment, use
#
#     $ conda activate r4.4
#
# To deactivate an active environment, use
#
#     $ conda deactivate

进入R4.4环境 

conda activate r4.4

使用mamba代替condao安装R 4.4

mamba install -y -c conda-forge r=4.4

 按R进入R语言界面安装devtools

install.packages("devtools")

 每次首次运行会让选择源,我会选20

如果安装发现源比较慢或有些包下载不下来,可以通过命令调出界面重新选择

chooseCRANmirror(graphics=FALSE)

 安装经过一段时间出现如下报错 

ERROR: dependencies ‘usethis’, ‘miniUI’, ‘pkgdown’, ‘rcmdcheck’, ‘roxygen2’, ‘rversions’, ‘urlchecker’ are not available for package ‘devtools’
Warning messages:
1: In install.packages("devtools") :installation of package ‘httpuv’ had non-zero exit status
2: In install.packages("devtools") :installation of package ‘ragg’ had non-zero exit status
3: In install.packages("devtools") :installation of package ‘xml2’ had non-zero exit status
4: In install.packages("devtools") :installation of package ‘shiny’ had non-zero exit status
5: In install.packages("devtools") :installation of package ‘pkgdown’ had non-zero exit status
6: In install.packages("devtools") :installation of package ‘roxygen2’ had non-zero exit status
7: In install.packages("devtools") :installation of package ‘rversions’ had non-zero exit status
8: In install.packages("devtools") :installation of package ‘urlchecker’ had non-zero exit status
9: In install.packages("devtools") :installation of package ‘miniUI’ had non-zero exit status
10: In install.packages("devtools") :installation of package ‘devtools’ had non-zero exit status

 退出R,使用下面命令安装,提示缺什么包就安装r-xxx包。

mamba install -y -c conda-forge r-usethis
mamba install -y r-httpuv
mamba install -y r-ragg
mamba install -y r-xml2
mamba install -y r-shiny
mamba install -y r-pkgdown
mamba install -y r-roxygen2
mamba install -y r-rversions
mamba install -y r-urlchecker
mamba install -y r-miniUI
R #进入R操作界面
install.packages("devtools")
 更新R包
install.packages("rvcheck")
rvcheck::update_all()

参考文档:Conda快速安装的解决方法(Mamba安装)_conda_TiYong-开放原子开发者工作坊


http://www.mrgr.cn/news/83148.html

相关文章:

  • SQL中的数据库对象
  • 基于物联网疫苗冷链物流监测系统设计
  • 蓝桥杯训练
  • 《框架程序设计》Java-SSM框架复习
  • Python在心血管医疗高维数据精准降维的应用:方法、应用与创新
  • 漏洞扫描工具
  • 如何在Windows上编译OpenCV4.7.0
  • Node.js中的fs模块:文件写入与读取
  • leetcode78.子集
  • (四)ROS通信编程——服务通信
  • Mapper XML 文件纳入 classpath 的解决方案
  • 微信小程序实现登录注册
  • C# 元组
  • 聚类系列 (二)——HDBSCAN算法详解
  • Vue3(一)
  • docker+ffmpeg+nginx+rtmp 拉取摄像机视频
  • vs2022开发.net窗体应用开发环境安装配置以及程序发布详细教程
  • 创建基本的 Electron 应用项目的详细步骤
  • spark汇总
  • 【W800】UART 的使用与问题
  • 电脑硬盘系统迁移及问题处理
  • C# 特性
  • Qt 5.14.2 学习记录 —— 팔 QWidget 常用控件(3)
  • 个人博客搭建(二)—Typora+PicGo+OSS
  • 学习记录:C++基类构造函数的调用:理解和实践
  • selenium+pyqt5自动化工具总结