Can not install h5py on Jetson AGX Xavier

I am trying to install h5py (2.10.0) on Jetson AGX Xavier (tried on L4T 32.6.1 and L4T 32.2.1) and get the following error:
Building wheels for collected packages: h5py
Building wheel for h5py (setup.py) … error
ERROR: Command errored out with exit status 1:
command: /home/nvidia/Downloads/test_venv/env37/bin/python3.7 -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-yged9cfn/h5py_98c9faacbfa04368a2c43021475a31d0/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-yged9cfn/h5py_98c9faacbfa04368a2c43021475a31d0/setup.py’“'”‘;f = getattr(tokenize, ‘"’“‘open’”’“‘, open)(file) if os.path.exists(file) else io.StringIO(’”‘“‘from setuptools import setup; setup()’”’“‘);code = f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ bdist_wheel -d /tmp/pip-wheel-lvcmvyf0
cwd: /tmp/pip-install-yged9cfn/h5py_98c9faacbfa04368a2c43021475a31d0/
Complete output (1319 lines):

/tmp/pip-install-yged9cfn/h5py_98c9faacbfa04368a2c43021475a31d0/h5py/defs.c:53:10: fatal error: Python.h: No such file or directory
#include “Python.h”
^~~~~~~~~~
compilation terminated.
error: command ‘aarch64-linux-gnu-gcc’ failed with exit status 1

ERROR: Failed building wheel for h5py
Running setup.py clean for h5py
Failed to build h5py
Installing collected packages: h5py
Running setup.py install for h5py … error
ERROR: Command errored out with exit status 1:
command: /home/nvidia/Downloads/test_venv/env37/bin/python3.7 -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-yged9cfn/h5py_98c9faacbfa04368a2c43021475a31d0/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-yged9cfn/h5py_98c9faacbfa04368a2c43021475a31d0/setup.py’“'”‘;f = getattr(tokenize, ‘"’“‘open’”’“‘, open)(file) if os.path.exists(file) else io.StringIO(’”‘“‘from setuptools import setup; setup()’”’“‘);code = f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record /tmp/pip-record-_lu31pu1/install-record.txt --single-version-externally-managed --compile --install-headers /home/nvidia/Downloads/test_venv/env37/include/site/python3.7/h5py
cwd: /tmp/pip-install-yged9cfn/h5py_98c9faacbfa04368a2c43021475a31d0/
Complete output (1318 lines):

/tmp/pip-install-yged9cfn/h5py_98c9faacbfa04368a2c43021475a31d0/h5py/defs.c:53:10: fatal error: Python.h: No such file or directory
#include “Python.h”
^~~~~~~~~~
compilation terminated.
error: command ‘aarch64-linux-gnu-gcc’ failed with exit status 1

ERROR: Command errored out with exit status 1: /home/nvidia/Downloads/test_venv/env37/bin/python3.7 -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-yged9cfn/h5py_98c9faacbfa04368a2c43021475a31d0/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-yged9cfn/h5py_98c9faacbfa04368a2c43021475a31d0/setup.py’“'”‘;f = getattr(tokenize, ‘"’“‘open’”’“‘, open)(file) if os.path.exists(file) else io.StringIO(’”‘“‘from setuptools import setup; setup()’”’“‘);code = f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record /tmp/pip-record-_lu31pu1/install-record.txt --single-version-externally-managed --compile --install-headers /home/nvidia/Downloads/test_venv/env37/include/site/python3.7/h5py Check the logs for full command output.

What the problem can be?

Hi @andhover

Did you install python3-dev?

If you are trying to install it on the target (as host), you can do it with:

# Python
sudo apt-get install python-dev
# Python3
sudo apt-get install python3-dev 

It will depend on if you are using an environment or not. Additionally, if you are cross-compiling, you might need to also add the development packages for Python as well.

Regards,
Leon

I’m trying to install on virtual env with python3.7 installed python3-dev early. I tried one more time and find that it was installed for python 3.6

python3-dev is already the newest version (3.6.7-1~18.04).

May be this is the reason? How to install python-dev 3.7?

Hi @andhover,

Ok. You may try:

sudo apt install python3.7-dev

What are you using for creating virtual-env?. I have seen that with miniconda/anaconda, it tends to be easier.

Regards,
Leon.

I’m using virtualenv:

sudo apt update && sudo apt install virtualenv
virtualenv --python=python3.7 envname
source envname/bin/activate

Anyway it works! Thanks a lot ;)

1 Like