Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 3.2: can't import sqlite3 module

I've just installed python 3.2.2 on ubuntu 10.04.3 (following all instraction from readme file) and tried to import sqlite3 module - the result:

No module named _sqlite3

Then I've looked into lib-dynload directory and there is no file _sqlite3.so (but it is in python 2.6).

How to fix this problem?

Thanks!

like image 298
Vitalii Ponomar Avatar asked Dec 25 '11 08:12

Vitalii Ponomar


People also ask

Do I need to pip install sqlite3?

You don't need to install sqlite3 module. It is included in the standard library (since Python 2.5).


2 Answers

If you installed from source, you need to install the development libraries for sqlite3.

sudo apt-get install libsqlite3-dev

You probably also want to install libreadline-dev and libssl-dev.

like image 91
casevh Avatar answered Oct 18 '22 18:10

casevh


Download python 3.3.2 http://www.python.org/getit/

The development libraries for sqlite3 (and other modules like readline, ssl, etc.) need to be installed before compiling Python from source. The C source code for the Python sqlite module is included with Python's source; however it requires the presence of sqlite3's development file to compile. It is not a separate library but part of Python.

If you installed from source, you need to install the development libraries for sqlite3.

sudo apt-get install libsqlite3-dev

What are the packages/libraries I should install before compiling Python from source? https://askubuntu.com/questions/21547/what-are-the-packages-libraries-i-should-install-before-compiling-python-from-so

sudo apt-get install libreadline-dev
sudo apt-get install libssl-dev

List of common dev environments ...

build-essential (obviously)
libz-dev        (also pretty common and essential)
libreadline-dev (or the Python prompt is crap)
libncursesw5-dev
libssl-dev
libgdbm-dev
libsqlite3-dev
libbz2-dev
liblzma-dev
tk-dev
libdb-dev
libncursesw5-dev
libreadline5-dev
libssl-dev
libgdbm-dev
libc6-dev

Install Python

tar xf Python-3.3.2.tar.xz
./configure
make
sudo make all install
like image 43
The Demz Avatar answered Oct 18 '22 17:10

The Demz