Python 3.2: unable to import sqlite3 module

I just installed python 3.2.2 on ubuntu 10.04.3 (after just starting from the readme file) and tried to import the sqlite3 module - the result:

No module named _sqlite3 

Then I looked at the lib-dynload directory and not the _sqlite3.so file (but it is in python 2.6).

How to solve this problem?

Thanks!

+7
python
source share
4 answers

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

 sudo apt-get install libsqlite3-dev 

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

+9
source share

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

development libraries for sqlite3 (and other modules, such as readline, ssl, etc.) need to be installed before compiling Python from source. The C source code for the sqlite Python module is included in the Python source; however, compiling it requires the sqlite3 development file. This is not a separate library, but part of Python.

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

 sudo apt-get install libsqlite3-dev 

What are the packages / libraries that I have to install before compiling Python from the 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 development 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 libsqlite3-dev 

Install python

 tar xf Python-3.3.2.tar.xz ./configure make sudo make all install 
+8
source share

My Python 3.4.1 had the same problem on ubuntu 12.04 when I use the SQLAlchemy library . The reason was because other people related to this question suggested that my system did not have a development package that was installed before I compiled and installed python 3.4.1. So I did:

 sudo apt-get install libsqlite3-dev 

And then went to my extracted python source and did re-complication like the steps described in the answers to this question. Then I could:

 Python 3.4.1 (default) [GCC 4.6.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sqlite3 >>> 
+1
source share

sqlite3 is not included in the python package, you can install it from the port: database / py -sqlite3. Since there are no specific versions of python3, you need to set PYTHON_VERSION = python3.5 before building. Both versions of 2.x and 3.x can coexist peacefully.

make -C / usr / ports / databases / py-sqlite3 PYTHON_VERSION = 3.5 install

0
source share

All Articles