pip install pysqlite leads to the following error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 and `#include "sqlite3.h"`

Nathan Basanese picture Nathan Basanese · Jun 17, 2015 · Viewed 7.6k times · Source

pip install pysqlite fails, and outputs the following with the following error log:

➜  ~  pip install pysqlite
Collecting pysqlite
  Using cached pysqlite-2.6.3.tar.gz
Installing collected packages: pysqlite
  Running setup.py install for pysqlite
    Complete output from command /home/nathan/.virtualenvs/tox/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-KwYD65/pysqlite/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-K7uywC-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/nathan/.virtualenvs/tox/include/site/python2.7/pysqlite:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/pysqlite2
    copying lib/__init__.py -> build/lib.linux-x86_64-2.7/pysqlite2
    copying lib/dump.py -> build/lib.linux-x86_64-2.7/pysqlite2
    copying lib/dbapi2.py -> build/lib.linux-x86_64-2.7/pysqlite2
    creating build/lib.linux-x86_64-2.7/pysqlite2/test
    copying lib/test/types.py -> build/lib.linux-x86_64-2.7/pysqlite2/test
    copying lib/test/userfunctions.py -> build/lib.linux-x86_64-2.7/pysqlite2/test
    copying lib/test/transactions.py -> build/lib.linux-x86_64-2.7/pysqlite2/test
    copying lib/test/factory.py -> build/lib.linux-x86_64-2.7/pysqlite2/test
    copying lib/test/hooks.py -> build/lib.linux-x86_64-2.7/pysqlite2/test
    copying lib/test/__init__.py -> build/lib.linux-x86_64-2.7/pysqlite2/test
    copying lib/test/regression.py -> build/lib.linux-x86_64-2.7/pysqlite2/test
    copying lib/test/dump.py -> build/lib.linux-x86_64-2.7/pysqlite2/test
    copying lib/test/dbapi.py -> build/lib.linux-x86_64-2.7/pysqlite2/test
    creating build/lib.linux-x86_64-2.7/pysqlite2/test/py25
    copying lib/test/py25/__init__.py -> build/lib.linux-x86_64-2.7/pysqlite2/test/py25
    copying lib/test/py25/py25tests.py -> build/lib.linux-x86_64-2.7/pysqlite2/test/py25
    running build_ext
    building 'pysqlite2._sqlite' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/src
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DMODULE_NAME="pysqlite2.dbapi2" -DSQLITE_OMIT_LOAD_EXTENSION=1 -I/usr/include/python2.7 -c src/module.c -o build/temp.linux-x86_64-2.7/src/module.o
    In file included from src/module.c:24:0:
    src/connection.h:33:21: fatal error: sqlite3.h: No such file or directory
     #include "sqlite3.h"
                         ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/home/nathan/.virtualenvs/tox/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-KwYD65/pysqlite/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-K7uywC-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/nathan/.virtualenvs/tox/include/site/python2.7/pysqlite" failed with error code 1 in /tmp/pip-build-KwYD65/pysqlite
 ➜  ~

Had a quick look around the rest of the stackoverflow village, and found this:

"error: command 'x86_64-linux-gnu-gcc' failed with exit status 1" in virtualenv

It seems similar, but doesn't have much to do with sqlite. Regardless, the solutions offered there did not work for this problem.

I have installed sqlite using sudo apt-get install sqlite, sqlite3 using sudo apt-get instal sqlite3 and installed sqlitebrowser using sudo apt-get install sqlitebrowser.

enter image description here

There are several other options that zsh autocomplete gives me for sqlite, but they mostly look like documentation or unrelated specialized extensions.

I searched for possible other dependencies using Aptitude, as follows (aptitude search sqlite): http://0bin.net/paste/-uv52OUbPGa5t-RJ#6VI1bgLbKqdhTUwBue0pO9yF63F3yfF++GtozB0ZI7S

I don't think it would be wise to go down the list and install whichever libraries strike my fancy, trying each time along the way, when I'm sure someone else has run into this problem before.

The PySQLite documentation doesn't seem to have much information on Debian dependencies, either. https://readthedocs.org/search/project/?q=dependency&selected_facets=project_exact%3Apysqlite

My theory is I just need The Right Library. If you don't know the right one with which to make an answer, please feel free to comment with advice on how to start searching more productively.

How do I fix the command 'x86_64-linux-gnu-gcc' failed with exit status 1...#include "sqlite3.h" error for the gcc compilation step of pip install pysqlite?

Answer

webster58 picture webster58 · Aug 27, 2015

There is no such headers, maybe You forgot to install them :) linux installs them seperatly with libsqlite3-dev

sudo apt-get install libsqlite3-dev