【发布时间】:2019-10-03 17:12:34
【问题描述】:
我已部分删除 Anaconda R。Base R 现在默认运行。但是,当我使用基本 R 安装 some R 软件包时,它们会失败。我认为他们失败是因为与 anaconda 的旧符号链接。
我想删除 Anaconda R,因为包版本冲突太多。
我正在使用 Linux Mint 19(即 Ubuntu 18.04)。
我按照post 删除了 Anaconda R。因此,我做到了:
conda uninstall r-baseconda uninstall r-*
现在which R 返回/usr/bin/R。如果我使用R从linux命令行加载R,然后在R中运行version,我得到:
> version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 3
minor 6.1
year 2019
month 07
day 05
svn rev 76782
language R
version.string R version 3.6.1 (2019-07-05)
nickname Action of the Toes
如果我尝试安装 install.packages("forecast") 之类的软件包(以下任何失败的软件包都会发生这种情况 quadprog、fracdiff 等),然后我会收到以下错误消息:
> install.packages("forecast")
Installing package into ‘/home/sav/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
also installing the dependencies ‘quadprog’, ‘fracdiff’, ‘tseries’, ‘RcppArmadillo’
trying URL 'https://cloud.r-project.org/src/contrib/quadprog_1.5-7.tar.gz'
Content type 'application/x-gzip' length 35925 bytes (35 KB)
==================================================
downloaded 35 KB
trying URL 'https://cloud.r-project.org/src/contrib/fracdiff_1.4-2.tar.gz'
Content type 'application/x-gzip' length 57636 bytes (56 KB)
==================================================
downloaded 56 KB
trying URL 'https://cloud.r-project.org/src/contrib/tseries_0.10-47.tar.gz'
Content type 'application/x-gzip' length 164796 bytes (160 KB)
==================================================
downloaded 160 KB
trying URL 'https://cloud.r-project.org/src/contrib/RcppArmadillo_0.9.700.2.0.tar.gz'
Content type 'application/x-gzip' length 1366153 bytes (1.3 MB)
==================================================
downloaded 1.3 MB
trying URL 'https://cloud.r-project.org/src/contrib/forecast_8.9.tar.gz'
Content type 'application/x-gzip' length 829958 bytes (810 KB)
==================================================
downloaded 810 KB
* installing *source* package ‘quadprog’ ...
** package ‘quadprog’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gfortran -fno-optimize-sibling-calls -fvisibility=hidden -fvisibility=hidden -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -msse2 -mfpmath=sse -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -c aind.f -o aind.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c init.c -o init.o
gfortran -fno-optimize-sibling-calls -fvisibility=hidden -fvisibility=hidden -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -msse2 -mfpmath=sse -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -c solve.QP.compact.f -o solve.QP.compact.o
gfortran -fno-optimize-sibling-calls -fvisibility=hidden -fvisibility=hidden -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -msse2 -mfpmath=sse -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -c solve.QP.f -o solve.QP.o
gfortran -fno-optimize-sibling-calls -fvisibility=hidden -fvisibility=hidden -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -msse2 -mfpmath=sse -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -c util.f -o util.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o quadprog.so aind.o init.o solve.QP.compact.o solve.QP.o util.o -lblas -lgfortran -lm -lquadmath -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
/home/sav/anaconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.2.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:6: quadprog.so] Error 1
ERROR: compilation failed for package ‘quadprog’
* removing ‘/home/sav/R/x86_64-pc-linux-gnu-library/3.6/quadprog’
* installing *source* package ‘fracdiff’ ...
** package ‘fracdiff’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c fdcore.c -o fdcore.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c fdgam.c -o fdgam.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c fdhess.c -o fdhess.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c fdmin.c -o fdmin.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c fdsim.c -o fdsim.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c init.c -o init.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c pmult.c -o pmult.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o fracdiff.so fdcore.o fdgam.o fdhess.o fdmin.o fdsim.o init.o pmult.o -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
/home/sav/anaconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.2.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:6: fracdiff.so] Error 1
ERROR: compilation failed for package ‘fracdiff’
* removing ‘/home/sav/R/x86_64-pc-linux-gnu-library/3.6/fracdiff’
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
** using staged installation
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ -std=gnu++11 accepts -g... yes
checking how to run the C++ preprocessor... g++ -std=gnu++11 -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ -std=gnu++11 accepts -g... (cached) yes
checking whether g++ version is sufficient... yes, with OpenMP as version 7.2.0
checking for macOS... checking LAPACK_LIBS... system LAPACK found
checking for OpenMP... found and suitable
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I"/home/sav/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppArmadillo.cpp -o RcppArmadillo.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I"/home/sav/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I"/home/sav/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c fastLm.cpp -o fastLm.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -fopenmp -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
/home/sav/anaconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.2.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -llapack
/home/sav/anaconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.2.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:6: RcppArmadillo.so] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/home/sav/R/x86_64-pc-linux-gnu-library/3.6/RcppArmadillo’
ERROR: dependency ‘quadprog’ is not available for package ‘tseries’
* removing ‘/home/sav/R/x86_64-pc-linux-gnu-library/3.6/tseries’
ERROR: dependencies ‘fracdiff’, ‘tseries’, ‘RcppArmadillo’ are not available for package ‘forecast’
* removing ‘/home/sav/R/x86_64-pc-linux-gnu-library/3.6/forecast’
The downloaded source packages are in
‘/tmp/RtmpS4CVTK/downloaded_packages’
Warning messages:
1: In install.packages("forecast") :
installation of package ‘quadprog’ had non-zero exit status
2: In install.packages("forecast") :
installation of package ‘fracdiff’ had non-zero exit status
3: In install.packages("forecast") :
installation of package ‘RcppArmadillo’ had non-zero exit status
4: In install.packages("forecast") :
installation of package ‘tseries’ had non-zero exit status
5: In install.packages("forecast") :
installation of package ‘forecast’ had non-zero exit status
从错误代码中,我可以确定gcc 编译器开始出现问题。看起来我的基本 R 安装正在尝试访问位于 /home/sav/anaconda3/bin/ 的 anaconda3 文件夹中的二进制文件:
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o quadprog.so aind.o init.o solve.QP.compact.o solve.QP.o util.o -lblas -lgfortran -lm -lquadmath -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
/home/sav/anaconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.2.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
注意我不想删除 anaconda3 文件夹,因为它包含重要的 Python 包。
此外,问题并非特定于 forecast 包。如果我选择RcppArmadillo,我会遇到类似的错误。罪魁祸首是
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -fopenmp -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
/home/sav/anaconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.2.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -llapack
/home/sav/anaconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.2.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:6: RcppArmadillo.so] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
我的~/.bashrc 包含以下几行
# added by Anaconda3 installer
# export PATH="/home/sav/anaconda3/bin:$PATH"
# added by Anaconda3 installer
export PATH="/home/sav/anaconda3/bin:$PATH"
. /home/sav/anaconda3/etc/profile.d/conda.sh
【问题讨论】:
-
sudo apt-get install r-cran-forecast...试试看。 -
该命令返回错误
E: Unable to locate package r-cran-forecast。 -
我假设您使用的是 ubuntu。也许那是错误的。以下是如何添加存储库以获取 r-cran-foo 包...cran.r-project.org/bin/linux/ubuntu
-
命令
ldconfig -p | grep -E "lib(blas|lapack)"返回以下liblapack.so.3 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/liblapack.so.3 liblapack.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/liblapack.so libblas.so.3 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libblas.so.3 libblas.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libblas.so