2

I have python3 installed on linux. In the python interpreter, I tried

import sqlite3

and got

ImportError: No module named '_sqlite3'

so i installed sqlite with

sudo apt-get install libsqlite-dev

and then recompiled python according to the instructions in the README file:

cd ~/Python-3.4.2;
./configure;
make;
make test;

and during test there was an error saying

[ 97/389] test_sqlite
test_sqlite skipped -- No module named '_sqlite3'

and then when I finished the install and tried to run the same python code, I still got the same ImportError. What am I doing wrong?

---EDIT---

I tried

pip install pysqlite

and got this error, which seems to be an issue between Python2.7 and Python3.4:

Downloading/unpacking pysqlite
  Downloading pysqlite-2.6.3.tar.gz (76kB): 76kB downloaded
  Running setup.py (path:/tmp/pip_build_plat/pysqlite/setup.py) egg_info for package pysqlite
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_plat/pysqlite/setup.py", line 85
        print "Is sphinx installed? If not, try 'sudo easy_install sphinx'."
                                                                           ^
    SyntaxError: Missing parentheses in call to 'print'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_plat/pysqlite/setup.py", line 85

    print "Is sphinx installed? If not, try 'sudo easy_install sphinx'."

                                                                       ^

SyntaxError: Missing parentheses in call to 'print'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_plat/pysqlite
Storing debug log for failure in /home/plat/.pip/pip.log
Platatat
  • 65
  • 1
  • 8
  • The package you are trying to install is not compatible with Python 3. – Martijn Pieters Feb 24 '15 at 18:00
  • The issue is that your Python was built *without* sqlite support; where the `sqlite` development headers installed when you compiled it? – Martijn Pieters Feb 24 '15 at 18:01
  • This might be a dupe of [How to install pysqlite for python3.4.2](http://stackoverflow.com/q/26438307) but that post wasn't answered. – Martijn Pieters Feb 24 '15 at 18:02
  • I ran into the same problem. My fix was to 'apt-get install libsqlite3-dev' and not 'libsqlite3-dev'. I assume libsqlite-dev is for python 2 and not python 3. After that the make test passed. – breeden Jun 30 '15 at 03:57

1 Answers1

-1

After install libsqlite-dev you should install pysqlite

pip install pysqlite
simopopov
  • 854
  • 5
  • 12