Can't seem to install Python's sqlite3 support

I'm trying to install Python2.7 with sqlite support in FreeBSD 10. I've installed the ports for both lang/python27, databases/sqlite3 and databases/py-sqlite3, but when trying to import the module inside python, it gives me the following error:
Code:
Python 2.7.8 (default, Oct 10 2014, 09:11:28)
[GCC 4.2.1 Compatible FreeBSD Clang 3.3 (tags/RELEASE_33/final 183502)] on freebsd10
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
    from dbapi2 import *
  File "/usr/local/lib/python2.7/sqlite3/dbapi2.py", line 28, in <module>
    from _sqlite3 import *
ImportError: No module named _sqlite3

Any idea how to get sqlite support in python 2.7? Do I need any other package?
 
I'm not fluent in Python but I can imagine that the module is named differently. Have you tried to import sqlite instead of sqlite3?

You can also have a look at pkg info -l py-sqlite. This will show a list of files the package installs. Perhaps you can find the correct name from there.
 
I've found the issue, but I don't really know if its a port problem or a problem on my side.

The Makefile for databases/py-sqlite3 has the following line:
Code:
PYDISTUTILS_INSTALLARGS+=       --install-lib ${PYTHON_LIBDIR}/lib-dynload
Which in my case gets translated to:
Code:
--install-lib /usr/local/lib/2.7/lib-dynload
There it installs both the _sqlite3.so and their .egg-info directory.

Python warns that it is unable to find it, so I just copied it to /usr/local/lib/python2.7/site-packages, where the rest of the Python libraries usually are. Now with this change, I can import sqlite3 inside Python2.7 without issues.

Any idea if I have to define PYTHON_LIBDIR myself? Inside the Makefile isn't any other reference to that variable, so I don't really know where it gets its value.
 
Back
Top