How to use sqlite3 in python on FreeBSD 10.3?

Eir Nym eirnym at gmail.com
Wed Jun 15 12:13:12 UTC 2016


Hi, Nan,


> On 15 Jun 2016, at 12:32, Nan Xiao <nan at chinadtrace.org> wrote:
> 
> 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/__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
> 
> Could anyone help on this issue? Thanks very much in advance!
> 

You should install databases/py-sqlite3 port for your system. This port as any other python library depends on python versions installed. You can read about specifying python version to build this library for in Handbook.

> 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 xmpp.ru.net 
> Telegram: nanxiao
> Personal website (Chinese): http://nanxiao.me/ 
> Personal website (English): http://nanxiao.me/en 
> Chinese DTrace website: http://chinadtrace.org/ 
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"



More information about the freebsd-questions mailing list