jnwatson / py-lmdb

Universal Python binding for the LMDB 'Lightning' Database
http://lmdb.readthedocs.io/
Other
645 stars 106 forks source link

can not install lmdb with python2.7 #369

Closed Light-- closed 3 weeks ago

Light-- commented 3 weeks ago

I need to use lmdb in python2.7. will not use python3

the error report:

pip2 install lmdb==1.4
...

Building wheels for collected packages: lmdb
  Building wheel for lmdb (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-Uo5ack/lmdb/setup.py'"'"'; __file__='"'"'/tmp/pip-install-Uo5ack/lmdb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-5Z0hFg
       cwd: /tmp/pip-install-Uo5ack/lmdb/
  Complete output (30 lines):
  py-lmdb: Using bundled liblmdb with py-lmdb patches; override with LMDB_FORCE_SYSTEM=1 or LMDB_PURE=1.
  patching file lmdb.h
  patching file mdb.c
  py-lmdb: Using CPython extension; override with LMDB_FORCE_CFFI=1.
  running bdist_wheel
  running build
  running build_py
  creating build/lib.linux-x86_64-2.7
  creating build/lib.linux-x86_64-2.7/lmdb
  copying lmdb/_config.py -> build/lib.linux-x86_64-2.7/lmdb
  copying lmdb/__init__.py -> build/lib.linux-x86_64-2.7/lmdb
  copying lmdb/cffi.py -> build/lib.linux-x86_64-2.7/lmdb
  copying lmdb/__main__.py -> build/lib.linux-x86_64-2.7/lmdb
  copying lmdb/tool.py -> build/lib.linux-x86_64-2.7/lmdb
  running build_ext
  There is a workaround to now inherit optimization CFLAGS when compiling wheels.
  To enable this, set APPLY_LP2002043_UBUNTU_CFLAGS_WORKAROUND in your
  environment. See LP: https://launchpad.net/bugs/2002043 for further context.
  APPLY_LP2002043_UBUNTU_CFLAGS_WORKAROUND not detected.
  building 'cpython' extension
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/lmdb
  creating build/temp.linux-x86_64-2.7/build
  creating build/temp.linux-x86_64-2.7/build/lib
  x86_64-linux-gnu-gcc -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -ffile-prefix-map=/build/python2.7-RH0SVf/python2.7-2.7.18=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Ilib/py-lmdb -Ibuild/lib -I/usr/include/python2.7 -c lmdb/cpython.c -o build/temp.linux-x86_64-2.7/lmdb/cpython.o -DHAVE_PATCHED_LMDB=1 -UNDEBUG -w
  lmdb/cpython.c:26:10: fatal error: Python.h: No such file or directory
     26 | #include "Python.h"
        |          ^~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for lmdb
  Running setup.py clean for lmdb
Failed to build lmdb
Installing collected packages: lmdb
    Running setup.py install for lmdb ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-Uo5ack/lmdb/setup.py'"'"'; __file__='"'"'/tmp/pip-install-Uo5ack/lmdb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-c4_Te3/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/wjc/.local/include/python2.7/lmdb
         cwd: /tmp/pip-install-Uo5ack/lmdb/
    Complete output (30 lines):
    py-lmdb: Using bundled liblmdb with py-lmdb patches; override with LMDB_FORCE_SYSTEM=1 or LMDB_PURE=1.
    patching file lmdb.h
    patching file mdb.c
    py-lmdb: Using CPython extension; override with LMDB_FORCE_CFFI=1.
    running install
    running build
    running build_py
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/lmdb
    copying lmdb/_config.py -> build/lib.linux-x86_64-2.7/lmdb
    copying lmdb/__init__.py -> build/lib.linux-x86_64-2.7/lmdb
    copying lmdb/cffi.py -> build/lib.linux-x86_64-2.7/lmdb
    copying lmdb/__main__.py -> build/lib.linux-x86_64-2.7/lmdb
    copying lmdb/tool.py -> build/lib.linux-x86_64-2.7/lmdb
    running build_ext
    There is a workaround to now inherit optimization CFLAGS when compiling wheels.
    To enable this, set APPLY_LP2002043_UBUNTU_CFLAGS_WORKAROUND in your
    environment. See LP: https://launchpad.net/bugs/2002043 for further context.
    APPLY_LP2002043_UBUNTU_CFLAGS_WORKAROUND not detected.
    building 'cpython' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/lmdb
    creating build/temp.linux-x86_64-2.7/build
    creating build/temp.linux-x86_64-2.7/build/lib
    x86_64-linux-gnu-gcc -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -ffile-prefix-map=/build/python2.7-RH0SVf/python2.7-2.7.18=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Ilib/py-lmdb -Ibuild/lib -I/usr/include/python2.7 -c lmdb/cpython.c -o build/temp.linux-x86_64-2.7/lmdb/cpython.o -DHAVE_PATCHED_LMDB=1 -UNDEBUG -w
    lmdb/cpython.c:26:10: fatal error: Python.h: No such file or directory
       26 | #include "Python.h"
          |          ^~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-Uo5ack/lmdb/setup.py'"'"'; __file__='"'"'/tmp/pip-install-Uo5ack/lmdb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-c4_Te3/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/wjc/.local/include/python2.7/lmdb Check the logs for full command output.

env: ubuntu 22.04 pip 20.3.4 from /usr/lib/python2.7/dist-packages/pip (python 2.7)

Light-- commented 3 weeks ago

solved by

sudo apt-get install python2-dev