TAGS :Viewed: 13 - Published at: a few seconds ago

[ Using spatialite with 64 bit python's sqlite3 module on 64 bit Windows 7 ]

I've installed the spatialite DLL files from this page. I've alternately tried putting the 32 bit DLLs (mod_spatialite-4.2.0-win-x86.7z) into Windows' system32 folder, and the 64 bit files (mod_spatialite-4.3.0a-win-amd64.7z) into the SysWOW64 folder. I then do the following in python:

import sqlite3
conn = sqlite3.connect(":memory:")
conn.enable_load_extension(True)
conn.execute('SELECT load_extension("[name of spatialite dll file]")')

This produces the error message:

sqlite3.OperationalError: %1 is not a valid Win32 application.

Any suggestions on how to get spatialite to work specifically on 64 bit Win7, with 64 bit python?

Answer 1


Fixed it. In case someone else is having the same issue, I'll post the solution:

Step 1. Get the Spatialite DLLs:

Download the 64 bit versions (i.e. mod_spatialite-4.3.0a-win-amd64.7z) here. Unzip the archive, and put the files in Windows' System32 folder.

Step 2. Update the spatialite3 python module's DLL file:

If the sqlite3 module is installed, in your C:\Python[X.X]\DLL folder, there is a file called 'sqlite3.dll' - this default sqlite dll may not work with the new spatialite DLL. Replace the default DLL with the updated 64 bit sqlite3.dll from this site.