Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use sqlite3 in python on FreeBSD?

I 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

What other packages should I install?

like image 420
Nan Xiao Avatar asked Apr 16 '26 14:04

Nan Xiao


1 Answers

The root cause has been found, I installed databases/sqlite3, not databases/py-sqlite3. After installing databases/py-sqlite3, it works.

like image 168
Nan Xiao Avatar answered Apr 19 '26 03:04

Nan Xiao



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!