Ubuntu 18.04新装R后依赖包安装及加载报错求助
Hey there, let's break down and fix the issues you're facing with R packages like lubridate and forecast on Ubuntu 18.04.
What's Going Wrong?
Two main compatibility mismatches are causing your headaches:
- stringi/lubridate failure: The
stringipackage (a dependency of lubridate) can't findlibicui18n.so.57—this means your system is missing the required ICU library files. - forecast/curl failure: The
curlR package is trying to useCURL_OPENSSL_3, but Ubuntu 18.04's default libcurl version doesn't support that (it uses an olderCURL_OPENSSL_1.0.0instead).
Step-by-Step Solutions
1. Fix the stringi/lubridate Missing Library Error
First, install the system-level ICU development library that stringi needs:
sudo apt-get update && sudo apt-get install libicu-dev
Then reinstall the stringi package from source to ensure it links correctly with your system's ICU:
install.packages("stringi", type = "source", repos = "http://cran.us.r-project.org")
After this, loading lubridate should work without the missing library error.
2. Resolve the forecast/curl Version Mismatch
Ubuntu 18.04 doesn't have the CURL_OPENSSL_3 version that the pre-built curl R package expects. We need to build curl from source using your system's existing libcurl:
Step 1: Install system libcurl development files
Make sure you have the latest libcurl dev package installed:
sudo apt-get install libcurl4-openssl-dev
Step 2: Reinstall curl R package with system libcurl
Fire up R and run this command to force building curl against your system's libcurl:
install.packages("curl", type = "source", configure.args = "--with-libcurl=/usr/lib/x86_64-linux-gnu/")
Step 3: Reinstall forecast
Now that curl is properly linked, reinstall the forecast package:
install.packages("forecast", repos = "http://cran.us.r-project.org")
You should now be able to load forecast without any issues:
library(forecast)
Quick Note on the BH Package Warning
That warning about std::auto_ptr being deprecated in the BH package is nothing to worry about—it's just a heads-up from the Boost library that an old feature is being phased out. It won't break any functionality, so you can safely ignore it.
内容的提问来源于stack exchange,提问作者Blairg23

