0

I am trying to load sqlite 64 bit while running Python 2.7 64 bit. I can do this interactively, but, not from a script.

Interactive:

$ /c/Python27-64/python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>>

From this script, one single line, the same as was done from the python shell:

import sqlite3

Run from command line:

$ /c/Python27-64/python test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import sqlite3
  File "c:\Python27-64\lib\sqlite3\__init__.py", line 24, in <module>
    from dbapi2 import *
  File "c:\Python27-64\lib\sqlite3\dbapi2.py", line 28, in <module>
    from _sqlite3 import *
ImportError: DLL load failed: %1 is not a valid Win32 application.

The script is obviously finding a 32 bit dll. But why? What is the difference between interactive and from the single line script? How is the DLL search being modified?

Doo Dah
  • 3,979
  • 13
  • 55
  • 74

1 Answers1

0

In case anyone runs into this, the problem was the file _sqlite3.pyd in the directory I was running the script. Can someone explain why Python creates it's own version of the Windows dll? Is this simply wrapped so that Python can make calls into it? Perhaps a ctypes wrapper?

Doo Dah
  • 3,979
  • 13
  • 55
  • 74