Using Sqlite, Python 2.7 and Spatialite?

The version of sqlite3.dll included with Python doesn't seem to want to play nice with Spatialite. The only thing I could get to work (short of compiling everything from source) was:

  1. Download SQLite (or cyqlite - a recompile of SQLite for Windows with some handy features enabled, such as R-Tree so you can do spaital indexes) i.e. sqlite-dll-win32-x86-[version].zip
  2. Download mod_spatialite (Windows binaries are in the pink box at the bottom of the page) i.e. mod_spatialite-[version]-win-x86.7z
  3. Unzip first SQLite/cyqlite then mod_spatialite into the same folder (overwrite if there are any conflicts)
  4. Add this folder to your system Path
  5. Rename the sqlite3.dll that is in your Python DLLs directory, to something like sqlite3_old.dll, so that Python will use the new one on your path

See this blog post for more info.


this thread may be a bit old - but i ran into a somewhat similar issue a couple of months back

i think this post was also related - Sqlite, Python 2.7 and Spatialite

i ended up finding another build of libspatialite-4.dll here http://latuviitta.org/documents/Spatialite_4.0_test_with_jre_1.6.zip although it is also labeled as 'test'...

after placing this build of libspatialite-4 in my python27/DLLs, it seemed to work.