# Pip install pynq error: drm.h missing

**URL:** <https://discuss.pynq.io/t/pip-install-pynq-error-drm-h-missing/2336>\
**Category:** Support\
**Created:** [February 15, 2021, 3:33pm UTC](https://discuss.pynq.io/t/pip-install-pynq-error-drm-h-missing/2336 "2021-02-15T15:33:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![balintmaci](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/balintmaci/32/1651_2.png) [@balintmaci](https://discuss.pynq.io/u/balintmaci)\
**Post date:** [February 15, 2021, 3:33pm UTC](https://discuss.pynq.io/t/pip-install-pynq-error-drm-h-missing/2336/1 "2021-02-15T15:33:03Z")

</div>

Hi there!  
So I’m trying to install pynq under Ubuntu 20. I tried with the [ros:noetic-perception-focal](https://hub.docker.com/layers/ros/library/ros/noetic-perception-focal/images/sha256-0fb955d7218b4c59d889d96f3db475700f000f94e2eeb451a22edd8fb826fc46?context=explore) docker image and I also tried with an Ubuntu 20 based image running directly on the Ultra96v2 board.

In both cases running `pip3 install pynq` (with or without sudo) results in a build error. First it misses `xf86drm.h`, so I install `libdrm-dev` with apt, and then on the next run it misses `drm.h`.

The error message:

```auto
creating build/lib/pynq/tests
    copying pynq/tests/test_pl.py -> build/lib/pynq/tests
    copying pynq/tests/test_mmio.py -> build/lib/pynq/tests
    copying pynq/tests/util.py -> build/lib/pynq/tests
    copying pynq/tests/test_su.py -> build/lib/pynq/tests
    copying pynq/tests/test_gpio.py -> build/lib/pynq/tests
    creating build/lib/pynq/lib/tests
    copying pynq/lib/tests/test_rgbled.py -> build/lib/pynq/lib/tests
    copying pynq/lib/tests/test_audio.py -> build/lib/pynq/lib/tests
    copying pynq/lib/tests/test_video.py -> build/lib/pynq/lib/tests
    copying pynq/lib/tests/test_switch.py -> build/lib/pynq/lib/tests
    copying pynq/lib/tests/test_led.py -> build/lib/pynq/lib/tests
    copying pynq/lib/tests/test_button.py -> build/lib/pynq/lib/tests
    copying pynq/lib/tests/pynq_welcome.pdm -> build/lib/pynq/lib/tests
    running build_ext
    make PYNQ_BUILD_ARCH=aarch64 -C pynq/lib/_pynq/_displayport/
    make: Entering directory '/tmp/pip-install-dp14u5s_/pynq/pynq/lib/_pynq/_displayport'
    g++ -fPIC -I=/usr/include/libdrm -c -g -std=c++11 displayport.cpp
    In file included from displayport.cpp:14:
    /usr/include/xf86drm.h:40:10: fatal error: drm.h: No such file or directory
       40 | #include <drm.h>
          | ^ ~~~~~~
    compilation terminated.
    make: *** [Makefile:8: all] Error 1
    make: Leaving directory '/tmp/pip-install-dp14u5s_/pynq/pynq/lib/_pynq/_displayport'
    error: command 'make' failed with exit status 2
    ----------------------------------------

```

`drm.h` can be found in both `/usr/include/drm/` and `/usr/include/libdrm/`

```auto
$ ll /usr/include/libdrm
total 576
drwxr-xr-x 3 root root 4096 Feb 15 21:04 ./
drwxr-xr-x 127 root root 16384 Feb 15 21:04 ../
-rw-r--r-- 1 root root 31894 May 27 2020 amdgpu_drm.h
-rw-r--r-- 1 root root 55079 May 27 2020 amdgpu.h
-rw-r--r-- 1 root root 32818 May 27 2020 drm_fourcc.h
-rw-r--r-- 1 root root 32306 May 27 2020 drm.h
-rw-r--r-- 1 root root 24920 May 27 2020 drm_mode.h
-rw-r--r-- 1 root root 2782 May 27 2020 drm_sarea.h
-rw-r--r-- 1 root root 6977 May 27 2020 etnaviv_drmif.h
-rw-r--r-- 1 root root 62951 May 27 2020 i915_drm.h
-rw-r--r-- 1 root root 7895 May 27 2020 mach64_drm.h
-rw-r--r-- 1 root root 13010 May 27 2020 mga_drm.h
-rw-r--r-- 1 root root 12105 May 27 2020 msm_drm.h
drwxr-xr-x 3 root root 4096 Feb 15 21:04 nouveau/
-rw-r--r-- 1 root root 7000 May 27 2020 nouveau_drm.h
-rw-r--r-- 1 root root 4131 May 27 2020 qxl_drm.h
-rw-r--r-- 1 root root 10000 May 27 2020 r128_drm.h
-rw-r--r-- 1 root root 16388 May 27 2020 r600_pci_ids.h
-rw-r--r-- 1 root root 1991 May 27 2020 radeon_bo_gem.h
-rw-r--r-- 1 root root 2839 May 27 2020 radeon_bo.h
-rw-r--r-- 1 root root 1678 May 27 2020 radeon_bo_int.h
-rw-r--r-- 1 root root 1601 May 27 2020 radeon_cs_gem.h
-rw-r--r-- 1 root root 5121 May 27 2020 radeon_cs.h
-rw-r--r-- 1 root root 2179 May 27 2020 radeon_cs_int.h
-rw-r--r-- 1 root root 38317 May 27 2020 radeon_drm.h
-rw-r--r-- 1 root root 5968 May 27 2020 radeon_surface.h
-rw-r--r-- 1 root root 7170 May 27 2020 savage_drm.h
-rw-r--r-- 1 root root 2633 May 27 2020 sis_drm.h
-rw-r--r-- 1 root root 14877 May 27 2020 tegra_drm.h
-rw-r--r-- 1 root root 2406 May 27 2020 tegra.h
-rw-r--r-- 1 root root 14457 May 27 2020 vc4_drm.h
-rw-r--r-- 1 root root 16906 May 27 2020 vc4_packet.h
-rw-r--r-- 1 root root 8244 May 27 2020 vc4_qpu_defines.h
-rw-r--r-- 1 root root 8372 May 27 2020 via_drm.h
-rw-r--r-- 1 root root 5010 May 27 2020 virtgpu_drm.h
-rw-r--r-- 1 root root 32085 May 27 2020 vmwgfx_drm.h

```

Any ideas on how to solve this missing dependency?

---

<div class="post-metadata">

**Author:** ![PeterOgden](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/peterogden/32/55_2.png) [@PeterOgden](https://discuss.pynq.io/u/PeterOgden)\
**Post date:** [February 15, 2021, 3:44pm UTC](https://discuss.pynq.io/t/pip-install-pynq-error-drm-h-missing/2336/2 "2021-02-15T15:44:38Z")

</div>

Try adding `--sysroot=/` to `CFLAGS` and `CXXFLAGS`

Peter

---

<div class="post-metadata">

**Author:** ![balintmaci](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/balintmaci/32/1651_2.png) [@balintmaci](https://discuss.pynq.io/u/balintmaci)\
**Post date:** [February 15, 2021, 8:24pm UTC](https://discuss.pynq.io/t/pip-install-pynq-error-drm-h-missing/2336/3 "2021-02-15T20:24:21Z")

</div>

Thanks Peter, I think that got me a step further, but it still breaks:

```auto
running build_ext
    make PYNQ_BUILD_ARCH=aarch64 -C pynq/lib/_pynq/_displayport/
    make: Entering directory '/tmp/pip-install-4fjom1q7/pynq/pynq/lib/_pynq/_displayport'
    g++ -fPIC -I=/usr/include/libdrm -c -g -std=c++11 displayport.cpp --sysroot=/
    displayport.cpp: In member function ‘void pynqvideo::device::enumerate_modes()’:
    displayport.cpp:334:69: warning: narrowing conversion of ‘(uint32_t)mode._drmModeModeInfo::vrefresh’ from ‘uint32_t’ {aka ‘unsigned int’} to ‘int’ [-Wnarrowing]
      334 | m_modes.push_back(video_mode{mode.hdisplay, mode.vdisplay, mode.vrefresh});
          | ~~~~~^~~~~~~~
    g++ -shared -fPIC -rdynamic displayport.o -ldrm -o libdisplayport.so --sysroot=/
    rm *.o
    make: Leaving directory '/tmp/pip-install-4fjom1q7/pynq/pynq/lib/_pynq/_displayport'
    copying pynq/lib/_pynq/_displayport/libdisplayport.so -> build/lib/pynq/lib/video
    make PYNQ_BUILD_ARCH=aarch64 -C pynq/lib/_pynq/_xhdmi/
    make: Entering directory '/tmp/pip-install-4fjom1q7/pynq/pynq/lib/_pynq/_xhdmi'
    make -C .. -f embeddedsw_lib.mk
    make[1]: Entering directory '/tmp/pip-install-4fjom1q7/pynq/pynq/lib/_pynq'
    cc -o _xhdmi/libxhdmi.so -shared -fPIC -Icommon -Icommon/aarch64 -Iembeddedsw/XilinxProcessorIPLib/drivers/v_hdmi_common/src -Iembeddedsw/XilinxProcessorIPLib/drivers/v_hdmirxss/src -Iembeddedsw/XilinxProcessorIPLib/drivers/v_hdmirx/src -Iembeddedsw/XilinxProcessorIPLib/drivers/v_hdmitxss/src -Iembeddedsw/XilinxProcessorIPLib/drivers/v_hdmitx/src -Iembeddedsw/XilinxProcessorIPLib/drivers/video_common/src -Iembeddedsw/XilinxProcessorIPLib/drivers/vphy/src -Iembeddedsw/XilinxProcessorIPLib/drivers/vtc/src -Iembeddedsw/lib/bsp/standalone/src/common -Iembeddedsw/lib/bsp/standalone/src/arm/common/gcc -Iembeddedsw/lib/bsp/standalone/src/arm/common -Iembeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/ -Iembeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/platform/ZynqMP/ _xhdmi/xv_hdmirx_g.c _xhdmi/xv_hdmitx_g.c _xhdmi/xvtc_g.c _xhdmi/xv_hdmirxss_g.c _xhdmi/xvphy_g.c _xhdmi/hdmi_functions.c _xhdmi/xv_hdmitxss_g.c common/xil_stubs.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmi_common/src/xv_hdmic_vsif.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmi_common/src/xv_hdmic.c 
embeddedsw/XilinxProcessorIPLib/drivers/v_hdmirxss/src/xv_hdmirxss_log.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmirxss/src/xv_hdmirxss_sinit.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmirxss/src/xv_hdmirxss_coreinit.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmirxss/src/xv_hdmirxss_hdcp.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmirxss/src/xv_hdmirxss.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmirx/src/xv_hdmirx_sinit.c 
embeddedsw/XilinxProcessorIPLib/drivers/v_hdmirx/src/xv_hdmirx.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmirx/src/xv_hdmirx_vsif.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmirx/src/xv_hdmirx_intr.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmirx/src/xv_hdmirx_selftest.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmitxss/src/xv_hdmitxss.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmitxss/src/xv_hdmitxss_sinit.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmitxss/src/xv_hdmitxss_coreinit.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmitxss/src/xv_hdmitxss_hdcp.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmitxss/src/xv_hdmitxss_log.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmitx/src/xv_hdmitx_selftest.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmitx/src/xv_hdmitx_sinit.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmitx/src/xv_hdmitx.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmitx/src/xv_hdmitx_vsif.c embeddedsw/XilinxProcessorIPLib/drivers/v_hdmitx/src/xv_hdmitx_intr.c embeddedsw/XilinxProcessorIPLib/drivers/video_common/src/xvidc_parse_edid.c embeddedsw/XilinxProcessorIPLib/drivers/video_common/src/xvidc_edid.c embeddedsw/XilinxProcessorIPLib/drivers/video_common/src/xvidc_edid_ext.c embeddedsw/XilinxProcessorIPLib/drivers/video_common/src/xvidc_timings_table.c embeddedsw/XilinxProcessorIPLib/drivers/video_common/src/xvidc.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_mmcme3.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_hdmi_intr.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_mmcme2.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_gthe3.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_selftest.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_sinit.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_i.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_gtxe2.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_gthe2.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_hdmi.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_gtpe2.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_intr.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_gtye4.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_mmcme4.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_dp.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_gthe4.c embeddedsw/XilinxProcessorIPLib/drivers/vphy/src/xvphy_log.c embeddedsw/XilinxProcessorIPLib/drivers/vtc/src/xvtc.c embeddedsw/XilinxProcessorIPLib/drivers/vtc/src/xvtc_selftest.c embeddedsw/XilinxProcessorIPLib/drivers/vtc/src/xvtc_sinit.c embeddedsw/XilinxProcessorIPLib/drivers/vtc/src/xvtc_intr.c --sysroot=/
    _xhdmi/hdmi_functions.c:5:10: fatal error: libxlnk_cma.h: No such file or directory
        5 | #include <libxlnk_cma.h>
          | ^ ~~~~~~~~~~~~~~
    compilation terminated.
    make[1]: *** [embeddedsw_lib.mk:31: _xhdmi/libxhdmi.so] Error 1
    make[1]: Leaving directory '/tmp/pip-install-4fjom1q7/pynq/pynq/lib/_pynq'
    make: *** [Makefile:7: all] Error 2
    make: Leaving directory '/tmp/pip-install-4fjom1q7/pynq/pynq/lib/_pynq/_xhdmi'
    error: command 'make' failed with exit status 2

```

by the way it’s the same with `sudo -E pip3 install --upgrade --upgrade-strategy only-if-needed pynq` and just `pip3 install pynq`

---

<div class="post-metadata">

**Author:** ![PeterOgden](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/peterogden/32/55_2.png) [@PeterOgden](https://discuss.pynq.io/u/PeterOgden)\
**Post date:** [February 15, 2021, 9:01pm UTC](https://discuss.pynq.io/t/pip-install-pynq-error-drm-h-missing/2336/4 "2021-02-15T21:01:40Z")

</div>

Try cloning the repository and running `sudo make install` [here](https://github.com/Xilinx/PYNQ/tree/master/sdbuild/packages/libsds/libcma).

Peter

---

<div class="post-metadata">

**Author:** ![balintmaci](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/balintmaci/32/1651_2.png) [@balintmaci](https://discuss.pynq.io/u/balintmaci)\
**Post date:** [February 15, 2021, 10:53pm UTC](https://discuss.pynq.io/t/pip-install-pynq-error-drm-h-missing/2336/5 "2021-02-15T22:53:10Z")

</div>

Thank you, this also seems to have helped, now the installation for pynq and pynq-dpu complete, but I’ve got a runtime error while trying to add the dpu notebooks.

```auto
$ pynq get-notebooks pynq-dpu -p .
/home/fpga/.local/lib/python3.8/site-packages/pynq/pl_server/device.py:81: UserWarning: No devices found, is the XRT environment sourced?
  warnings.warn(
Traceback (most recent call last):
  File "/home/fpga/.local/bin/pynq-get-notebooks", line 8, in <module>
    sys.exit(main())
  File "/home/fpga/.local/lib/python3.8/site-packages/pynq/_cli/get_notebooks.py", line 154, in main
    device = _detect_devices(active_only=True)
  File "/home/fpga/.local/lib/python3.8/site-packages/pynq/utils.py", line 164, in _detect_devices
    raise RuntimeError("No device found in the system")
RuntimeError: No device found in the system

```

I did some digging in the PYNQ repo and found that `export XILINX_XRT=/usr` is set as part of the XRT package so I set that variable, but of course it makes no sense if XRT is not installed. I tried to follow the steps in qemu.sh for XRT but when I run build.sh it exits without error instantly but the compiled files are nowhere to be found.

```auto
fpga@fpga:~/XRT/build$ time XRT_NATIVE_BUILD=no ./build.sh -dbg

real 0m0.032s
user 0m0.022s
sys 0m0.017s
fpga@fpga:~/XRT/build$ ll
total 84
drwxrwxr-x 3 fpga fpga 4096 Feb 16 07:31 ./
drwxrwxr-x 6 fpga fpga 4096 Feb 16 07:31 ../
-rwxrwxr-x 1 fpga fpga 8150 Feb 16 07:24 board.sh*
-rwxrwxr-x 1 fpga fpga 5061 Feb 16 07:24 build.bat*
-rw-rw-r-- 1 fpga fpga 3486 Feb 16 07:24 builddrv.bat
-rwxrwxr-x 1 fpga fpga 7885 Feb 16 07:31 build_edge.sh*
-rwxr-xr-x 1 fpga fpga 8116 Feb 16 07:31 build.sh*
-rwxrwxr-x 1 fpga fpga 3723 Feb 16 07:24 build-win.sh*
drwxrwxr-x 2 fpga fpga 4096 Feb 16 07:24 checkpatch/
-rwxrwxr-x 1 fpga fpga 487 Feb 16 07:24 checkpatch.sh*
-rwxrwxr-x 1 fpga fpga 2987 Feb 16 07:24 covbuild.sh*
-rwxrwxr-x 1 fpga fpga 5055 Feb 16 07:24 cross_compile.sh*
-rwxrwxr-x 1 fpga fpga 2144 Feb 16 07:24 dbg.sh*
-rw-rw-r-- 1 fpga fpga 95 Feb 16 07:24 petalinux.build
-rwxrwxr-x 1 fpga fpga 3455 Feb 16 07:31 run.sh*
-rw-rw-r-- 1 fpga fpga 403 Feb 16 07:24 toolchain-edge.cmake

```

I used tag 202020.2.8.743, which is the 2020.2 release, instead of the older one mentioned in the script. Reasoning is that the kernel of my image is also for 2020.2 and I believe it is the version that introduces Ubuntu 20 support.

edit: [the script file I used for instructions](https://github.com/Xilinx/PYNQ/blob/master/sdbuild/packages/xrt/qemu.sh)

---

<div class="post-metadata">

**Author:** ![PeterOgden](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/peterogden/32/55_2.png) [@PeterOgden](https://discuss.pynq.io/u/PeterOgden)\
**Post date:** [February 15, 2021, 11:08pm UTC](https://discuss.pynq.io/t/pip-install-pynq-error-drm-h-missing/2336/6 "2021-02-15T23:08:24Z")

</div>

I’ve no idea what’s going on with XRT - maybe @rock can help?

You have a second issue which is that your kernel or device-tree doesn’t contain the drivers for the `/dev/xlnk` device. You’ll need to make sure that CONFIG\_XILINX\_APF is set in your kernel and [this fragment](https://github.com/Xilinx/PYNQ/blob/master/sdbuild/boot/meta-pynq/recipes-bsp/device-tree/files/pynq_xlnk_zynqmp.dtsi) is in your device tree.

Peter

---

<div class="post-metadata">

**Author:** ![rock](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/rock/32/32_2.png) [@rock](https://discuss.pynq.io/u/rock)\
**Post date:** [February 16, 2021, 1:31pm UTC](https://discuss.pynq.io/t/pip-install-pynq-error-drm-h-missing/2336/7 "2021-02-16T13:31:37Z")

</div>

The output of `time XRT_NATIVE_BUILD=no ./build.sh -dbg` does not look correct to me. You will need to clear your XRT github repo and redo the `build.sh`. A correct output should be a long log of cmake build flow, where you can see XRT has been installed by percentage.
