"Unable to locate the SpatiaLite library." Django
<p>I'm trying to make Django's SQLite3 accept spatial queries. <a href="https://docs.djangoproject.com/en/1.10/ref/contrib/gis/install/spatialite/" rel="nofollow">This tutorial</a> suggests that I add this to settings:</p>

<pre><code>SPATIALITE_LIBRARY_PATH = 'mod_spatialite'
</code></pre>

<p>Which produces this error:</p>

<blockquote>
  <p>django.core.exceptions.ImproperlyConfigured: Unable to load the
  SpatiaLite library extension "mod_spatialite" because: The specified
  module could not be found.</p>
</blockquote>

<p>I also tried doing this : </p>

<pre><code>SPATIALITE_LIBRARY_PATH = r'C:\\Program Files (x86)\\Spatialite\\mod_spatialite-4.3.0a-win-x86\\mod_spatialite-4.3.0a-win-x86\\mod_spatialite.dll'
</code></pre>

<p>If I don't add this variable I receive this error when I migrate:</p>

<blockquote>
  <p>django.core.exceptions.ImproperlyConfigured: Unable to locate the
  SpatiaLite library. Make sure it is in your library path, or set
  SPATIALITE_LIBRARY_PATH in your settings.</p>
</blockquote>

<p>Thank you..</p>

<p>Amusingly enough 5 days later I'm having the same issue. After a little bit of poking around I got it working:</p>

<p>Set</p>

<pre><code>SPATIALITE_LIBRARY_PATH = 'mod_spatialite'
</code></pre>

<p>and extract ALL the DLL files from the mod_spatialite-x.x.x-win-x86.7z to your Python installation directory. The dll's apparently need to be in the same folder with python.exe. Also I imagine the mod_spatialite package needs to 32/64 bit according to your python installation.  If you're missing some dll's, you get the same error "specified module not found" regardless of what dll file is missing, so it's a bit misleading.</p>

<p>Downloaded from <a href="http://www.gaia-gis.it/gaia-sins/" rel="nofollow">http://www.gaia-gis.it/gaia-sins/</a></p>

<p>I used mod_spatialite stable version 4.3.0a x86 with Python 3.5.2 32-bit.</p>

<p>Other threads on the same issue with all sorts of answers:</p>

<ul>
<li><a href="http://stackoverflow.com/questions/27907818/use-spatialite-extension-for-sqlite-on-windows">Use spatialite extension for SQLite on Windows</a></li>
<li><a href="http://stackoverflow.com/questions/22667981/getting-a-working-spatialite-sqlite-system-for-x64-c-sharp">Getting a working SpatiaLite + SQLite system for x64 c#</a></li>
<li><a href="http://gis.stackexchange.com/questions/85674/sqlite-python-2-7-and-spatialite">http://gis.stackexchange.com/questions/85674/sqlite-python-2-7-and-spatialite</a></li>
</ul>

python django sqlite3 spatial geodjango