I am trying my hardest to utilize the work of the good folks at the GeoDa center, but I cannot seem to get all of the components to load. GDAL, in particular, has been giving me some difficulty. The biggest issue arises because I am operating within the IPython Notebook. If you are unfamiliar with the Notebook, to say it's worth a look is the understatement of the century.
In any event, after some difficulty and some assistance, I was able to install the GDAL module. It was even importable at the Python prompt:
Python 2.7.5 |Anaconda 1.6.1 (64-bit)| (default, Jun 28 2013, 22:10:09) [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import gdal >>>
However, after my difficulties in the Notebook, I went back to the IPython prompt to discover the following difficulty:
Python 2.7.5 |Anaconda 1.6.1 (64-bit)| (default, Jun 28 2013, 22:10:09) Type "copyright", "credits" or "license" for more information. IPython 1.0.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In : import gdal --------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-1-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
Has anyone else encountered this issue? I know that sqlite3 is an installed module already, so if I can't see it being a dependency issue. That being said, I am not sure where to start beyond poking around the osgeo source. Any thoughts would be greatly appreciated. (I am using Ubuntu 13.04, by the way.)
I first discovered this problem when having trouble with the R package, rgdal from within Notebook (but curiously not from within RStudio). Upon discovering deficiencies on the Python side as well, I thought it might be useful to talk to a more spatially-focused crowd.
UPDATE: Thank you for the prompt responses. With respect to the first comment (SQLite), how would I verify that one was using a different version from the other? I checked the paths in os.environment, and they are the same. Thoughts?
With respect to the latter, sys.executable was identical (and I initiated both from the same working directory):
>>> import sys, os >>> sys.executable '/home/choct155/analysis/Anaconda/bin/python'
In : import sys, os In : sys.executable Out: '/home/choct155/analysis/Anaconda/bin/python'
However, I did find differences in os.environ:
print set(python_environ.items())-set(ipython_environ.items()) print set(ipython_environ.items())-set(python_environ.items()) ***************************** set([('OLDPWD', '/home/choct155/analysis/fwtools/FWTools-linux-x86_64-3.0.6'), ('WINDOWID', '54529262'), ('_', '/home/choct155/analysis/Anaconda/bin/python'), ('C_INCLUDE_PATH', '/usr/include/gdal'), ('CPLUS_INCLUDE_PATH', '/usr/include/gdal')]) set([('WINDOWID', '54526233'), ('_', '/home/choct155/analysis/Anaconda/bin/ipython'), ('OLDPWD', '/tmp/pip-build-root/GDAL')])
To my eye, the environmental variables that I set in .bashrc (the include paths) are the elephant in the room. In fact, without these set, I couldn't get GDAL to install at all. What I am not clear on is why they would apply only to Python when IPython is using the same Python executable as the back end.
Sidenote: To those that are working with these tools, in general it's probably a good idea to check out minrk's github page and GeospatialPython.org.
UPDATE: Admittedly, I have very little theory behind this attempted fix, but I tried to harmonize the two environments by explicitly adding the missing environmental variables with a startup script in the default_profile for IPython. This, probably predictably, did not work. I am guessing that these variables are utilized only during installation. Since I already installed gdal...
!sudo pip install gdal ********************* Requirement already satisfied (use --upgrade to upgrade): gdal in /home/choct155/analysis/Anaconda/lib/python2.7/site-packages Cleaning up...
...I am still not sure how to remedy this. Further, I am still unclear on how and why my Python and IPython platforms would be looking at different versions of SQLite when they have the same PATH. Any help would be greatly appreciated!