peewee: Failing to install Peewee with Pip

Hi,

currently I am having a lot of trouble installing Peewee. When executing pip3 install -r requirements.txt on a Ubuntu 16.04 LTS I get

Collecting peewee~=3.6.1
  Using cached https://files.pythonhosted.org/packages/2c/08/b059dd7cc0fa6ae45af86f36660fb0838463390d5626d37b8595e54efd9e/peewee-3.6.1.tar.gz
Building wheels for collected packages: peewee
  Running setup.py bdist_wheel for peewee ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-weh5o8st/peewee/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpaceuk7nvpip-wheel- --python-tag cp35:
  /home/lmm/.local/lib/python3.5/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
    """)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
  copying peewee.py -> build/lib.linux-x86_64-3.5
  copying pwiz.py -> build/lib.linux-x86_64-3.5
  creating build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/fields.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/flask_utils.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/__init__.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/dataset.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/shortcuts.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/sqlite_ext.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/sqlcipher_ext.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/migrate.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/kv.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/apsw_ext.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/signals.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/sqliteq.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/test_utils.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/mysql_ext.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/sqlite_udf.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/hybrid.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/db_url.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/pool.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/postgres_ext.py -> build/lib.linux-x86_64-3.5/playhouse
  copying playhouse/reflection.py -> build/lib.linux-x86_64-3.5/playhouse
  running build_ext
  building 'playhouse._speedups' extension
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/playhouse
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c playhouse/_speedups.c -o build/temp.linux-x86_64-3.5/playhouse/_speedups.o
  x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.5/playhouse/_speedups.o -o build/lib.linux-x86_64-3.5/playhouse/_speedups.cpython-35m-x86_64-linux-gnu.so
  building 'playhouse._sqlite_udf' extension
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c playhouse/_sqlite_udf.c -o build/temp.linux-x86_64-3.5/playhouse/_sqlite_udf.o
  x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.5/playhouse/_sqlite_udf.o -o build/lib.linux-x86_64-3.5/playhouse/_sqlite_udf.cpython-35m-x86_64-linux-gnu.so
  building 'playhouse._sqlite_ext' extension
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c playhouse/_sqlite_ext.c -o build/temp.linux-x86_64-3.5/playhouse/_sqlite_ext.o
  playhouse/_sqlite_ext.c:531:21: fatal error: sqlite3.h: No such file or directory
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for peewee
  Running setup.py clean for peewee
Failed to build peewee
Installing collected packages: peewee
  Running setup.py install for peewee ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-weh5o8st/peewee/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-_l2_k4ko-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    /home/lmm/.local/lib/python3.5/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
      """)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.5
    copying peewee.py -> build/lib.linux-x86_64-3.5
    copying pwiz.py -> build/lib.linux-x86_64-3.5
    creating build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/fields.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/flask_utils.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/__init__.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/dataset.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/shortcuts.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/sqlite_ext.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/sqlcipher_ext.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/migrate.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/kv.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/apsw_ext.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/signals.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/sqliteq.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/test_utils.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/mysql_ext.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/sqlite_udf.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/hybrid.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/db_url.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/pool.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/postgres_ext.py -> build/lib.linux-x86_64-3.5/playhouse
    copying playhouse/reflection.py -> build/lib.linux-x86_64-3.5/playhouse
    running build_ext
    building 'playhouse._speedups' extension
    creating build/temp.linux-x86_64-3.5
    creating build/temp.linux-x86_64-3.5/playhouse
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c playhouse/_speedups.c -o build/temp.linux-x86_64-3.5/playhouse/_speedups.o
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.5/playhouse/_speedups.o -o build/lib.linux-x86_64-3.5/playhouse/_speedups.cpython-35m-x86_64-linux-gnu.so
    building 'playhouse._sqlite_udf' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c playhouse/_sqlite_udf.c -o build/temp.linux-x86_64-3.5/playhouse/_sqlite_udf.o
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.5/playhouse/_sqlite_udf.o -o build/lib.linux-x86_64-3.5/playhouse/_sqlite_udf.cpython-35m-x86_64-linux-gnu.so
    building 'playhouse._sqlite_ext' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c playhouse/_sqlite_ext.c -o build/temp.linux-x86_64-3.5/playhouse/_sqlite_ext.o
    playhouse/_sqlite_ext.c:531:21: fatal error: sqlite3.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-weh5o8st/peewee/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-_l2_k4ko-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-weh5o8st/peewee/
You are using pip version 8.1.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

For me it seems related to the fact I do not have the sqlite dev package installed, but I would think this should not be required for installing peewee, or is it?

Thanks in advance!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Try:

export NO_SQLITE=1
pip install peewee

This will ensure that the SQLite C extensions are not built. They depend on libsqlite3 and the sqlite3.h header file, which you appear not to have installed on your system. Previously, these extensions would only be built if you also had Cython, but since in 3.6 I’ve added the pre-generated C files to the package, the extensions will be built.

There’s a bit of info here regarding the SQLite C extensions: http://docs.peewee-orm.com/en/latest/peewee/installation.html#skip-compilation-of-sqlite-extensions

I may have to revise the build if this is problematic for a lot of users, however.

Alright…I think I finally have a solution that should work for everyone. Pushed a new release, 3.6.4, which contains the changes.

I’ve changed approaches and now am using an approach similar to what simplejson does. First we’ll try to build the extensions (assuming we’re on CPython and not pypy or something), and if that fails we fall-back to a pure-python build.

This should fix the (admittedly baffling to me) situation where you have installed both Python and a C compiler, but not the header files.

The same issue here, but on different system. I think it’s due to the https://github.com/coleifer/peewee/blob/master/setup.py#L12, which’s now always True, and native extensions are always built. @coleifer can it be made tweakable?

Sure thing, thanks for verifying that @madelyneriksen – I had mistakenly assumed that the presence of the shared library would mean that the headers would be available also (for sqlite). At any rate, the fix in 3.6.4 should resolve the issue. If you wish to build the C extensions, you’ll want to install the libsqlite3-dev package (which should include sqlite3.h).

@coleifer it still tries to build _speedups extension and fails: screen shot 2018-07-18 at 19 27 43