Search code examples
pythonubuntupipblenderlmdb

lmdb/cpython.c:26:10: fatal error: Python.h: No such file or directory


[Disclaimer] I need to use same exact version Blender as well as the bundled Python that comes with it for PVNET-Rendering git repo. Steps to reproduce the error:

1.

root@fae597dbdb79:/home# wget https://bootstrap.pypa.io/pip/3.5/get-pip.py
--2023-12-15 18:28:14--  https://bootstrap.pypa.io/pip/3.5/get-pip.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.0.175, 151.101.64.175, 151.101.128.175, ...
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.0.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1908223 (1.8M) [text/x-python]
Saving to: 'get-pip.py'

get-pip.py                                         100%[================================================================================================================>]   1.82M  --.-KB/s    in 0.07s   

2023-12-15 18:28:20 (27.6 MB/s) - 'get-pip.py' saved [1908223/1908223]
  1. root@fae597dbdb79:/home# cd blender-2.79a-linux-glibc219-x86_64/2.79/python/bin/

root@fae597dbdb79:/home/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin# ./python3.5m  /home/get-pip.py 
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Collecting pip<21.0
  Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
     |################################| 1.5 MB 6.9 MB/s 
Collecting setuptools
  Using cached setuptools-50.3.2-py3-none-any.whl (785 kB)
Collecting wheel
  Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel, setuptools, pip
Successfully installed pip-20.3.4 setuptools-50.3.2 wheel-0.37.1

root@fae597dbdb79:/home/pvnet-rendering#  /home/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin/pip3 install lmdb
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Collecting lmdb
  Using cached lmdb-1.4.1.tar.gz (881 kB)
Building wheels for collected packages: lmdb
  Building wheel for lmdb (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin/python3.5m -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sz6nq7pp/lmdb_95a8258634164c42b71528bea9b99efe/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sz6nq7pp/lmdb_95a8258634164c42b71528bea9b99efe/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-eb8274q3
       cwd: /tmp/pip-install-sz6nq7pp/lmdb_95a8258634164c42b71528bea9b99efe/
  Complete output (26 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-3.5
  creating build/lib.linux-x86_64-3.5/lmdb
  copying lmdb/tool.py -> build/lib.linux-x86_64-3.5/lmdb
  copying lmdb/cffi.py -> build/lib.linux-x86_64-3.5/lmdb
  copying lmdb/__init__.py -> build/lib.linux-x86_64-3.5/lmdb
  copying lmdb/_config.py -> build/lib.linux-x86_64-3.5/lmdb
  copying lmdb/__main__.py -> build/lib.linux-x86_64-3.5/lmdb
  running build_ext
  building 'cpython' extension
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/lmdb
  creating build/temp.linux-x86_64-3.5/build
  creating build/temp.linux-x86_64-3.5/build/lib
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ilib/py-lmdb -Ibuild/lib -I/home/blender-2.79a-linux-glibc219-x86_64/2.79/python/include/python3.5m -c lmdb/cpython.c -o build/temp.linux-x86_64-3.5/lmdb/cpython.o -DHAVE_PATCHED_LMDB=1 -UNDEBUG -w
  lmdb/cpython.c:26:10: fatal error: Python.h: No such file or directory
   #include "Python.h"
            ^~~~~~~~~~
  compilation terminated.
  error: command '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: /home/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin/python3.5m -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sz6nq7pp/lmdb_95a8258634164c42b71528bea9b99efe/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sz6nq7pp/lmdb_95a8258634164c42b71528bea9b99efe/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-xca485a8/install-record.txt --single-version-externally-managed --compile --install-headers /home/blender-2.79a-linux-glibc219-x86_64/2.79/python/include/python3.5m/lmdb
         cwd: /tmp/pip-install-sz6nq7pp/lmdb_95a8258634164c42b71528bea9b99efe/
    Complete output (26 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-3.5
    creating build/lib.linux-x86_64-3.5/lmdb
    copying lmdb/tool.py -> build/lib.linux-x86_64-3.5/lmdb
    copying lmdb/cffi.py -> build/lib.linux-x86_64-3.5/lmdb
    copying lmdb/__init__.py -> build/lib.linux-x86_64-3.5/lmdb
    copying lmdb/_config.py -> build/lib.linux-x86_64-3.5/lmdb
    copying lmdb/__main__.py -> build/lib.linux-x86_64-3.5/lmdb
    running build_ext
    building 'cpython' extension
    creating build/temp.linux-x86_64-3.5
    creating build/temp.linux-x86_64-3.5/lmdb
    creating build/temp.linux-x86_64-3.5/build
    creating build/temp.linux-x86_64-3.5/build/lib
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ilib/py-lmdb -Ibuild/lib -I/home/blender-2.79a-linux-glibc219-x86_64/2.79/python/include/python3.5m -c lmdb/cpython.c -o build/temp.linux-x86_64-3.5/lmdb/cpython.o -DHAVE_PATCHED_LMDB=1 -UNDEBUG -w
    lmdb/cpython.c:26:10: fatal error: Python.h: No such file or directory
     #include "Python.h"
              ^~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin/python3.5m -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sz6nq7pp/lmdb_95a8258634164c42b71528bea9b99efe/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sz6nq7pp/lmdb_95a8258634164c42b71528bea9b99efe/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-xca485a8/install-record.txt --single-version-externally-managed --compile --install-headers /home/blender-2.79a-linux-glibc219-x86_64/2.79/python/include/python3.5m/lmdb Check the logs for full command output.

I am using Docker with Ubuntu 18.04 inside native Ubuntu 22.04.


Solution

  • It seems I was able to install it using the following command:

    root@fae597dbdb79:/home/pvnet-rendering# /home/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin/pip3 install lmdb --only-binary=:all:
    DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
    Collecting lmdb
      Downloading lmdb-1.2.1-cp35-cp35m-manylinux2010_x86_64.whl (297 kB)
         |################################| 297 kB 7.6 MB/s 
    Installing collected packages: lmdb
    Successfully installed lmdb-1.2.1