使用Knitr进行编织时,无法在RStudio中使用网状导入大熊猫

时间:2018-09-13 04:24:59

标签: python r knitr geopandas reticulate

我正在尝试在virtualenv内部使用网状结构和Python编织Rmd文件。 以下是我的R设置块:

```{r r-setup}
library(reticulate)

venv_path <- "/path/to/venv/"
use_virtualenv(venv_path, required = TRUE)
```

这按预期工作。但是,当我尝试导入Geopandas时,下一步将中断:

```{python}
import geopandas as gpd
```

回溯如下:

Error in py_module_import... OSError: Could not find lib c or load any variants...

回溯错误指向整齐的软件包from shapely.geometry import shape, Point File。其他Python库加载时在块内没有问题,例如import os

从这些消息中,我猜测它没有加载OGR / GDAL绑定。但是,我不确定该如何解决。

当我在笔记本中运行块时,

import geopandas运行不会出错。不编织。它也可以在我的项目的repl_python() shell中使用。因此,问题似乎主要与编织和编织有关。

我的RStudio版本是:1.1.456。

session_info()的输出是:

  

sessionInfo()

R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin17.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib

locale:
[1] en_NZ.UTF-8/en_NZ.UTF-8/en_NZ.UTF-8/C/en_NZ.UTF-8/en_NZ.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] reticulate_1.10 stringr_1.3.1   dplyr_0.7.6     ggplot2_3.0.0  

loaded via a namespace (and not attached):
[1] Rcpp_0.12.18     pillar_1.3.0     compiler_3.5.1   plyr_1.8.4      
[5] bindr_0.1.1      tools_3.5.1      digest_0.6.17    packrat_0.4.9-3 
[9] jsonlite_1.5     evaluate_0.11    tibble_1.4.2     gtable_0.2.0    
[13] lattice_0.20-35  pkgconfig_2.0.2  rlang_0.2.2      Matrix_1.2-14   
[17] yaml_2.2.0       bindrcpp_0.2.2   withr_2.1.2      knitr_1.20      
[21] rprojroot_1.3-2  grid_3.5.1       tidyselect_0.2.4 glue_1.3.0      
[25] R6_2.2.2         rmarkdown_1.10   purrr_0.2.5      magrittr_1.5    
[29] scales_1.0.0     backports_1.1.2  htmltools_0.3.6  assertthat_0.2.0
[33] colorspace_1.3-2 stringi_1.2.4    lazyeval_0.2.1   munsell_0.5.0   
[37] crayon_1.3.4

0 个答案:

没有答案