Question

Okay i've been battling for this for 2 days, that usually means its something too simple to realize.

I have an embedded linux system which I cross compile on my ubuntu. When compiling python, sqlite3 is not on the list of modules that have not been able to be compiled.

But, the _sqlite3.so library is not in the same location as for example json.so and ctypes.so array.so... in Python-2.6.6/build/lib.linux868-2.6/

The actual module with the init-functions etc is in the right place at : in Python-2.6.6/modules and it can also be found on the target system.

Since the so-file was missing, i tried compiling it myself as a shared library using my arm-compiler. This did not work either.

Without manually compiled so-file:

>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "rootfs/python/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
  File "rootfs/python/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
ImportError: /python/lib/python2.6/lib-dynload/_sqlite3.so: cannot open shared object file: No such file or directory

With the compiled shared library found at lib-dynloads:

>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "rootfs/python/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
  File "rootfs/python/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
ImportError: dynamic module does not define init function (init_sqlite3)

Edit: I was wondering if i had compiled the right library for sqlite3. As far as i now understand the _sqlite3.so is something the python builder makes and libsqlite3.so is the library it needs to build it? And libsqlite3.so is build from Sqlite3-source code. Am i mistaken here?

Anyone with more embedded Linux or Python experience have an idea what I am doing wrong here?

Was it helpful?

Solution 2

Ok, figured this out. Somehow I did not manually compile the SO-file correctly. Got this to work like so:

First from setup.py , I added verbose debugging enabled for sqlite3 module. This added a printout that solved the problem:

skipping incompatible /usr/lib/libsqlite3.so
cannot find -sqlite3

That made me realize that the setup.py had chosen the first path where it found any module named sqlite3, ignoring it's architecture alltogether. Removing other search paths from the setup.py, but the one i had the ARM compiled library in, made it work. The _sqlite3.so was compiled nicely with all the other modules.

OTHER TIPS

Try to compile and install sqlite3 first on your system, and compiler python later. Or just

easy_install pysqlite
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top