Linux安装R和Python

R 4.2.1安装

  1. R下载地址: https://mirrors.ustc.edu.cn/CRAN/
  2. 安装依赖:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    yum install libcurl-devel
    yum install readline-devel
    yum install libXt-devel
    yum install bzip2-deve
    yum install xz-devel.x86_64
    yum install pcre-devel
    yum install libpng-devel
    yum install libtiff-devel
    yum install libjpeg-turbo-devel
    yum install pango-devel

    # Ubuntu X11 dependencies
    sudo apt-get install libx11-dev
    sudo apt-get install xorg-dev
  3. 编译安装:
    1
    2
    3
    ./configure --prefix=/opt/software/R --enable-R-shlib=yes --with-pcre1 --with-libpng --with-x
    make
    make install
  4. R安装包:
    • 安装CRAN下载的包: install.packages("BiocManager")
      *下载地址(可以下载某个版本的包): https://cran.r-project.org/src/contrib/Archive/
    • 安装生信相关的包:
      1
      2
      3
      if (!requireNamespace("BiocManager", quietly = TRUE))
      install.packages("BiocManager")
      BiocManager::install("SingleR")
      *下载某个Bioconductor版本包的地址: http://bioconductor.org/about/release-announcements/
    • 安装下载的包(当安装的包需要更高的gcc版本时可以下载低版本的包):
      install.packages("/opt/KEGG.db_1.0.tar.gz",repos=NULL)
    • 安装指定地址的包:
      1
      2
      url <- "https://cran.r-project.org/src/contrib/Archive/rvcheck/rvcheck_0.1.8.tar.gz"
      install.packages(url, repos = NULL, type = "source")
    • 通过devtools安装:
      1
      2
      3
      4
      install.packages("devtools")
      library(devtools)
      install_version("edgeR", version = "3.14.0")
      devtools::install_github("davidaknowles/leafcutter/leafcutter")
    • 通过remotes安装:
      1
      2
      install.packages("remotes")
      remotes::install_github("LTLA/celldex")
  5. 包的管理:
    1
    2
    3
    4
    5
    6
    # 查看已安装的包
    installed.packages()
    # 查看包的版本
    packageVersion("spatstat.core")
    # 删除包
    remove.packages("SingleR")

Python 3.9.14安装

  1. Python下载地址: https://www.python.org/downloads/
  2. 安装依赖:
    1
    2
    3
    4
    5
    yum install libffi-devel
    yum install tcl-devel
    yum install tk-devel
    yum install sqlite-devel
    yum install gdbm-devel
  3. 编译安装:
    1
    2
    3
    ./configure --prefix=/opt/software/python
    make
    make install
  4. Python安装包:
    1
    2
    3
    python3 -m pip install numpy 
    python3 -m pip install pandas==2.0.1
    pip install numpy.whl
    *下载python包地址(当下载速度慢或高版本编译出错时选择):
    https://pypi.tuna.tsinghua.edu.cn/simple/
    https://www.lfd.uci.edu/~gohlke/pythonlibs/
Author: Giftbear
Link: https://giftbear.github.io/2023/03/25/Linux安装R和Python/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.