Jupyter配置IRkernel遇阻:install.packages("devtools")安装失败求助
Hey there, sorry to hear you're hitting a snag installing devtools while setting up IRkernel for Jupyter. Let's walk through some common fixes that usually resolve this issue:
devtools Installation Failures 1. Check Network & Switch to a Stable CRAN Mirror
Network glitches or slow mirrors are often the culprit. Try switching to a reliable mirror (like a domestic one if you're in China) and re-run the install command:
# Manually specify a stable CRAN mirror (e.g., Tsinghua University) install.packages("devtools", repos = "https://mirrors.tuna.tsinghua.edu.cn/CRAN/")
Also, make sure your network isn't blocked by a firewall or proxy—try temporarily disabling proxies if you're using them.
2. Install System-Level Dependencies
devtools relies on several system libraries that aren't included with R by default. Install them based on your OS:
- Ubuntu/Debian Linux:
Open your terminal and run:sudo apt-get install build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev - macOS:
If you use Homebrew, run:
(If you don't have Homebrew installed, grab it first before running the above command.)brew install curl openssl libxml2 - Windows:
Install the matching version of Rtools for your R release, and ensure it's added to your system PATH during installation.
3. Resolve Individual Dependency Failures
Sometimes devtools fails because one of its dependent packages won't install. Look for specific error messages (e.g., "failed to install package 'httr'") and manually install that dependency first:
# Example: If httr is the problematic package install.packages("httr")
Once all dependencies are installed successfully, try installing devtools again.
4. Install Directly from GitHub (Last Resort)
If all else fails, you can install devtools directly from its GitHub repo. First make sure you have git installed on your system, then run:
# Install git2r first (required for GitHub installs) install.packages("git2r") # Install devtools from GitHub library(git2r) install_git("https://github.com/r-lib/devtools.git")
Once devtools installs without issues, you can get back to setting up IRkernel as per the official guide. If you run into specific error codes or messages, feel free to share them—they'll help narrow down the problem even faster!
内容的提问来源于stack exchange,提问作者sheetal_158

