ubuntu上的rgdal安装难度16.04 LTS

时间:2017-06-06 05:59:11

标签: r ubuntu

我搜索了一个答案,帮助我的情况避免重复,但无济于事。

我想在ubuntu 16.04 LTS上将'rgdal'软件包安装到R上。如果我在R-studio中编码如下

install.packages("rgdal", type = "source")

它会出现以下错误;

Installing package into ‘/home/kocesat/R/x86_64-pc-linux-gnu-library/3.2’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘rgdal’ is not available (for R version 3.2.3)

然后我尝试安装libgdal1-dev,libproj-dev,如下所示

$ sudo apt-get install libgdal1-dev libproj-dev

它成功安装了dev文件。然后我尝试使用相同的命令在R-studio中再次安装“rgdal”。它不再起作用了。

然后我安装了自制软件并尝试使用

获取gdal
~$ brew install gdal

它返回了

Error: undefined method `rebuild' for    
#<BottleSpecification:0x000000015ddc60>
Please report this bug:
https://github.com/Linuxbrew/linuxbrew/blob/master/share/doc/homebrew  
/Troubleshooting.md#troubleshooting
/home/kocesat/.linuxbrew/Library/Taps/homebrew/homebrew-core/Formula  
/jpeg.rb:9:in `block in <class:Jpeg>'
/home/kocesat/.linuxbrew/Library/Homebrew/software_spec.rb:91:in  
`instance_eval'
/home/kocesat/.linuxbrew/Library/Homebrew/software_spec.rb:91:in `bottle'
/home/kocesat/.linuxbrew/Library/Homebrew/formula.rb:1729:in `bottle'
/home/kocesat/.linuxbrew/Library/Taps/homebrew/homebrew-core/Formula
/jpeg.rb:7:in `<class:Jpeg>'
/home/kocesat/.linuxbrew/Library/Taps/homebrew/homebrew-core/Formula
/jpeg.rb:1:in `load_formula'
/home/kocesat/.linuxbrew/Library/Homebrew/formulary.rb:21:in `module_eval'
/home/kocesat/.linuxbrew/Library/Homebrew/formulary.rb:21:in 
`load_formula'
/home/kocesat/.linuxbrew/Library/Homebrew/formulary.rb:34:in
`load_formula_from_path'
/home/kocesat/.linuxbrew/Library/Homebrew/formulary.rb:83:in `load_file'
/home/kocesat/.linuxbrew/Library/Homebrew/formulary.rb:74:in `klass'
/home/kocesat/.linuxbrew/Library/Homebrew/formulary.rb:70:in `get_formula'
/home/kocesat/.linuxbrew/Library/Homebrew/formulary.rb:207:in `factory'
/home/kocesat/.linuxbrew/Library/Homebrew/dependency.rb:32:in `to_formula'
/home/kocesat/.linuxbrew/Library/Homebrew/dependency.rb:93:in `block in   
expand'
/home/kocesat/.linuxbrew/Library/Homebrew/dependencies.rb:9:in `each'
/home/kocesat/.linuxbrew/Library/Homebrew/dependencies.rb:9:in `each'
/home/kocesat/.linuxbrew/Library/Homebrew/dependency.rb:80:in `expand'
/home/kocesat/.linuxbrew/Library/Homebrew/formula.rb:1223:in 
`recursive_dependencies'
/home/kocesat/.linuxbrew/Library/Homebrew/requirement.rb:196:in `expand'
/home/kocesat/.linuxbrew/Library/Homebrew/formula.rb:1229:in `recursive_requirements'
/home/kocesat/.linuxbrew/Library/Homebrew/formula_installer.rb:313:in `expand_requirements'
/home/kocesat/.linuxbrew/Library/Homebrew/formula_installer.rb:263:in `compute_dependencies'
/home/kocesat/.linuxbrew/Library/Homebrew/formula_installer.rb:130:in `verify_deps_exist'
/home/kocesat/.linuxbrew/Library/Homebrew/formula_installer.rb:123:in `prelude'
/home/kocesat/.linuxbrew/Library/Homebrew/cmd/install.rb:231:in `install_formula'
/home/kocesat/.linuxbrew/Library/Homebrew/cmd/install.rb:93:in `block in install'
/home/kocesat/.linuxbrew/Library/Homebrew/cmd/install.rb:93:in `each'
/home/kocesat/.linuxbrew/Library/Homebrew/cmd/install.rb:93:in `install'
/home/kocesat/.linuxbrew/Library/brew.rb:84:in `<main>'

现在,我该怎么办?任何意见都将不胜感激。

2 个答案:

答案 0 :(得分:19)

以下是我用Ubuntu 16.04安装的最新R-cran PPA存储库:

sudo add-apt-repository 'deb https://mirror.ibcp.fr/pub/CRAN/bin/linux/ubuntu xenial/' 
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
sudo apt-get update
sudo apt-get install libgdal1-dev libproj-dev libgeos-dev
sudo apt-get install r-base-core

您可以根据您的位置使用其他CRAN镜像: https://cran.r-project.org/mirrors.html

然后,install.packages("rgdal")应该有用。

如果您想在Ubuntu LTS版本上使用最新的空间库,您还可以使用ubuntugis PPA:https://launchpad.net/~ubuntugis/+archive/ubuntu/ppa

sudo add-apt-repository 'deb http://ppa.launchpad.net/ubuntugis/ppa/ubuntu xenial main' 
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 314DF160
sudo apt update
sudo apt upgrade

答案 1 :(得分:0)

如果您由于travis集成失败而在这里,请参阅#5852

language: r
sudo: false
cache: packages
addons:
  apt:
    packages:
      - libgdal-dev
      - libproj-dev