在生成一些空间分析时,我一直在使用 IPython Notebook 将我的 Python 和 R 代码集成到一个工作流中。我以前能够将必要的基础设施导入两个命名空间来执行此任务,但我认为由于后续更新而发生了一些变化。特别是,我不再能够在%%R单元格中调用rgdal库:
%%R
library(rgdal)
***************
Loading required package: sp
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/choct155/R/x86_64-pc-linux-gnu-library/3.0/rgdal/libs/rgdal.so':
/usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name
Error: package or namespace load failed for ‘rgdal’
这很奇怪的原因是因为我可以在基础 R 和 RStudio 中调用库(输出相同):
> library(rgdal)
Loading required package: sp
rgdal: version: 0.8-11, (SVN revision 479M)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.10.0, released 2013/04/24
Path to GDAL shared files: /usr/share/gdal/1.10
Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
Path to PROJ.4 shared files: (autodetected)
RStudio 和 Notebook 中的版本信息是一样的……:
> version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 3
minor 0.1
year 2013
month 05
day 16
svn rev 62743
language R
version.string R version 3.0.1 (2013-05-16)
nickname Good Sport
...就像 R 的位置一样:
> Sys.which("R")
R
"/usr/bin/R"
请注意,我试图从笔记本中安装rgdal ...:
%%R
install.packages("rgdal")
************************
Installing package into ‘/home/choct155/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://watson.nci.nih.gov/cran_mirror/src/contrib/rgdal_0.8-11.tar.gz'
Content type 'application/octet-stream' length 1607285 bytes (1.5 Mb)
opened URL
==================================================
downloaded 1.5 Mb
The downloaded source packages are in
‘/tmp/RtmpDTrZOJ/downloaded_packages’
...并且它与已在 RStudio 中成功加载的版本相同:
> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=C LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rgdal_0.8-11 sp_1.0-11
loaded via a namespace (and not attached):
[1] grid_3.0.1 lattice_0.20-23 tools_3.0.1
有了这个,我对这里发生的事情不知所措。虽然我可以在 RStudio 中继续,但它会分散我尝试创建的产品。任何关于此事的建议将不胜感激。
附录:看来这可能不仅仅是 %rmagic 的问题。在尝试在 Python 中执行不同的操作时,我在尝试同时导入osgeo和gdal时收到以下错误:
import gdal
************************
ERROR: ImportError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name [IPython.core.interactiveshell]
ERROR:astropy:ImportError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-13-27bf4694dd2b> in <module>()
----> 1 import gdal
/home/choct155/analysis/Anaconda/lib/python2.7/site-packages/gdal.py in <module>()
1 # import osgeo.gdal as a convenience
----> 2 from osgeo.gdal import deprecation_warn
3 deprecation_warn('gdal')
4
5 from osgeo.gdal import *
/home/choct155/analysis/Anaconda/lib/python2.7/site-packages/osgeo/__init__.py in <module>()
19 fp.close()
20 return _mod
---> 21 _gdal = swig_import_helper()
22 del swig_import_helper
23 else:
/home/choct155/analysis/Anaconda/lib/python2.7/site-packages/osgeo/__init__.py in swig_import_helper()
15 if fp is not None:
16 try:
---> 17 _mod = imp.load_module('_gdal', fp, pathname, description)
18 finally:
19 fp.close()
ImportError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name
我真的只是再次安装了GDAL,所以我有最新的版本。想法?