我一直在使用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"
请注意,我尝试在Notebook ...中安装 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,但它会破坏我试图创建的产品。关于这个问题的任何建议将不胜感激。
ADDENDUM:看来这可能不仅仅是%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,因此我拥有最新版本。想法?