How to use sqlite3 in python on FreeBSD 10.3?

Nan Xiao nan at
Wed Jun 15 11:25:47 UTC 2016

Hi all,

Greetings from me! I am a newbie of FreeBSD, and want to use sqlite3 in python on my FreeBSD 10.3. After installing python, it prompts I should install the following additional packages:

Note that some standard Python modules are provided as separate ports
as they require additional dependencies. They are available as:
bsddb           databases/py-bsddb
gdbm            databases/py-gdbm
sqlite3         databases/py-sqlite3
tkinter         x11-toolkits/py-tkinter
From this post, it seems after installing above 4 packages, the sqlite3 should be able to work. But "impore sqlite3" still reports following errors:

>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/sqlite3/", line 24, in <module>
    from dbapi2 import *
  File "/usr/local/lib/python2.7/sqlite3/", line 28, in <module>
    from _sqlite3 import *
ImportError: No module named _sqlite3

Could anyone help on this issue? Thanks very much in advance!

Have a nice day!

P.S., I also submit this issue on SO, but unfortunately, I can't get any help from there, so I repost the question here, thanks! 

Best Regards
Nan Xiao (肖楠)
Skype: xiaonan19830818
Jabber/XMPP: nanxiao at 
Telegram: nanxiao
Personal website (Chinese): 
Personal website (English): 
Chinese DTrace website: 

More information about the freebsd-questions mailing list