首页 > 解决方案 > 在 Azure jupyter notebook 中安装 SpatialPosition 包时出错

问题描述

当我尝试使用以下方法在 jupyter notebook 中为 R 安装“SpatialPostion”时:

install.packages("SpatialPosition_2.0.1.tar.gz",repos=NULL,type="source")
options(unzip='internal')
library(SpatialPosition)

也尝试使用 Zip 文件(由于某些安全问题,我无法访问 Cran 站点),我收到此错误:

Error in library(SpatialPosition): there is no package called ‘SpatialPosition’
Traceback:
1. library(SpatialPosition)
2. stop(txt, domain = NA)**

我在这里尝试了很多可能的组合,但仍然总是遇到同样的错误。希望我能从你们那里得到合适的解决方案,可以成功运行。谢谢

标签: razurejupyter

解决方案


此安装过程(不尝试获取或解压缩 gz)是成功的。如果您在新的 R 会话中尝试此操作但仍然无法正常工作,则可以尝试使用早期版本的 R(这是在 3.6.3 上)。我可以确认该包可从 github 获得并且没有损坏:

> install.packages("remotes")
> library(remotes)
> remotes::install_github("Groupe-ElementR/SpatialPosition")
Downloading GitHub repo Groupe-ElementR/SpatialPosition@master
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All                                
2: CRAN packages only                 
3: None                               
4: Rcpp      (1.0.3 -> 1.0.4.6) [CRAN]
5: rlang     (0.4.5 -> 0.4.6  ) [CRAN]
6: withr     (2.1.2 -> 2.2.0  ) [CRAN]
7: pkgbuild  (1.0.6 -> 1.0.8  ) [CRAN]
8: backports (1.1.5 -> 1.1.6  ) [CRAN]
9: ps        (1.3.2 -> 1.3.3  ) [CRAN]

Enter one or more numbers, or an empty line to skip updates:

Installing 4 packages: sf, rgeos, raster, units
Installing packages into ‘C:/Users/User/Documents/R/win-library/3.6’ (as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/sf_0.9-3.zip'
Content type 'application/zip' length 42626142 bytes (40.7 MB)
downloaded 40.7 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/rgeos_0.5-3.zip'
Content type 'application/zip' length 2030318 bytes (1.9 MB)
downloaded 1.9 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/raster_3.1-5.zip'
Content type 'application/zip' length 3344411 bytes (3.2 MB)
downloaded 3.2 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/units_0.6-6.zip'
Content type 'application/zip' length 1759033 bytes (1.7 MB)
downloaded 1.7 MB

package ‘sf’ successfully unpacked and MD5 sums checked
package ‘rgeos’ successfully unpacked and MD5 sums checked
package ‘raster’ successfully unpacked and MD5 sums checked
package ‘units’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\User\AppData\Local\Temp\RtmpaGI1w7\downloaded_packages
√  checking for file 
'C:\Users\User\AppData\Local\Temp\RtmpaGI1w7\remotes8a0416e2c30\Groupe-ElementR-SpatialPosition-e425314/DESCRIPTION' ...
-  preparing 'SpatialPosition':
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  looking to see if a 'data/datalist' file should be added
-  building 'SpatialPosition_2.0.1.tar.gz'

Installing package into ‘C:/Users/User/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
* installing *source* package 'SpatialPosition' ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'SpatialPosition'
    finding HTML links ... done
    CreateDistMatrix                        html  
    CreateGrid                              html  
    SpatialPosition                         html  
    hospital                                html  
    huff                                    html  
    isopoly                                 html  
    mcStewart                               html  
    paris                                   html  
    plotHuff                                html  
    plotReilly                              html  
    plotStewart                             html  
    quickStewart                            html  
    rasterHuff                              html  
    rasterReilly                            html  
    finding level-2 HTML links ... done

    rasterStewart                           html  
    rasterToContourPoly                     html  
    reilly                                  html  
    smoothy                                 html  
    spatMask                                html  
    spatPts                                 html  
    spatUnits                               html  
    stewart                                 html  
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (SpatialPosition)
> library(SpatialPosition)
> 

这已成功安装sessionInfo()

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

推荐阅读