ModuleNotFoundError: No module named 'jinja2'

Good day,

I tried to build a simple sample: "blinky" using west build command for my nRF9160 DK.

However, file generation failed with the following errors: "ModuleNotFoundError: No module named 'jinja2' " and "ninja: build stopped: subcommand failed".

How can this problem be resolved?

I attach  Screenshot_1 (7-February-2023) that shows all error messages that showed up.

I also attach: CMakeOutput.log.

The CMakeError.log was empty.

Regards,

JM

Screenshot_1 (7-February-2023).docx

The target system is: Generic -  - cortex-m33+nodsp
The host system is: Windows - 10.0.19044 - AMD64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: C:/Users/zephyr-sdk-0.15.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe 
Build flags: -mcpu=cortex-m33+nodsp
Id flags: -c 

The output was:
0


Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.o"

The C compiler identification is GNU, found in "C:/Users/zephyrproject/zephyr/build/tfm/CMakeFiles/3.25.2/CompilerIdC/CMakeCCompilerId.o"

Checking whether the ASM compiler is GNU using "--version" matched "(GNU assembler)|(GCC)|(Free Software Foundation)":
arm-zephyr-eabi-gcc.exe (Zephyr SDK 0.15.2) 12.1.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  • Hello JM,

    Please attach your screenshot as an Image/Video/File in the ticket, or copy the list of errors and paste as "Code".

    The Blinky sample is not designed for the nRF9160. 

    What version of NCS are you working on? How did you build your project? Please provide more information to this ticket. 

    Kind regards,
    Øyvind

  • Hello  Oyvind,

    I am using nRF Connect SDK v2.2.99-dev3 and I am able to build the Blinky sample for my build target: nrf9160dk_nrf9160_ns without any problems and without any errors, when I use the nRF Connect SDK v2.2.99-dev3.

    In view of the above, I am surprised that you stated that "The Blinky sample is NOT designed for the nRF9160".

    I have been using the nRF Connect v2.2.99-dev3 and earlier versions of the nRF Connect SDK for a long time without major problems but now I want to start building applications/samples using "west build" command.

    And this is why I selected a simple sample: Blinky as my first attempt to use "west build" command.

    My approach to build my project using "west build" command was to enter the following line in the command prompt:

    west build --pristine --board [email protected] c:\nordic-2299\v2.2.99-dev3\zephyr\samples\basic\blinky

    I did paste a copy of the list of errors below (in Italic).

    I am not sure how to paste the list of errors as 'Code". Maybe you can explain.

    Regards,

    JM

    C:\Users\zephyrproject\zephyr>west build --pristine --board [email protected] c:\nordic-2299\v2.2.99-dev3\zephyr\samples\basic\blinky
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/Nordic-2299/v2.2.99-dev3/zephyr/samples/basic/blinky
    -- CMake version: 3.25.2
    -- Found Python3: C:/Users/Administrator/AppData/Local/Programs/Python/Python38/python.exe (found suitable exact version "3.8.10") found components: Interpreter
    -- Cache files will be written to: C:/Users/zephyrproject/zephyr/.cache
    -- Zephyr version: 3.2.99 (C:/Users/zephyrproject/zephyr)
    -- Found west (found suitable version "0.13.1", minimum required is "0.7.1")
    -- Board: nrf9160dk_nrf9160_ns, Revision: 1.0.1 (Active: 0.14.0)
    -- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
    -- Found host-tools: zephyr 0.15.2 (C:/Users/zephyr-sdk-0.15.2)
    -- Found toolchain: zephyr 0.15.2 (C:/Users/zephyr-sdk-0.15.2)
    -- Found Dtc: C:/ProgramData/chocolatey/bin/dtc.exe (found suitable version "1.5.0", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/Users/zephyrproject/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_ns.dts
    -- Found devicetree overlay: C:/Users/zephyrproject/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_ns_0_14_0.overlay
    'label' is marked as deprecated in 'properties:' in C:/Users/zephyrproject/zephyr/dts/bindings\gpio\nxp,pcal6408a.yaml for node /soc/peripheral@40000000/i2c@a000/pcal6408a@20.
    'label' is marked as deprecated in 'properties:' in C:/Users/zephyrproject/zephyr/dts/bindings\mtd\jedec,spi-nor.yaml for node /soc/peripheral@40000000/spi@b000/mx25r6435f@1.
    -- Generated zephyr.dts: C:/Users/zephyrproject/zephyr/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/Users/zephyrproject/zephyr/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/Users/zephyrproject/zephyr/build/zephyr/dts.cmake
    Parsing C:/Users/zephyrproject/zephyr/Kconfig
    Loaded configuration 'C:/Users/zephyrproject/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_ns_defconfig'
    Merged configuration 'C:/Nordic-2299/v2.2.99-dev3/zephyr/samples/basic/blinky/prj.conf'
    Configuration saved to 'C:/Users/zephyrproject/zephyr/build/zephyr/.config'
    Kconfig header saved to 'C:/Users/zephyrproject/zephyr/build/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 12.1.0
    -- The CXX compiler identification is GNU 12.1.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/Users/zephyr-sdk-0.15.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/Users/zephyrproject/zephyr/build
    -- west build: building application
    [1/182] Generating include/generated/version.h
    -- Zephyr version: 3.2.99 (C:/Users/zephyrproject/zephyr), build: zephyr-v3.2.0-4020-g67db251f140b
    [3/182] Generating include/generated/driver-validation.h
    FAILED: zephyr/include/generated/driver-validation.h C:/Users/zephyrproject/zephyr/build/zephyr/include/generated/driver-validation.h
    cmd.exe /C "cd /D C:\Users\zephyrproject\zephyr\build\zephyr && C:\Users\Administrator\AppData\Local\Programs\Python\Python38\python.exe C:/Users/zephyrproject/zephyr/scripts/build/gen_kobject_list.py --validation-output C:/Users/zephyrproject/zephyr/build/zephyr/include/generated/driver-validation.h --include-subsystem-list C:/Users/zephyrproject/zephyr/build/zephyr/misc/generated/struct_tags.json "
    Traceback (most recent call last):
    File "C:/Users/zephyrproject/zephyr/scripts/build/gen_kobject_list.py", line 62, in <module>
    import elftools
    ModuleNotFoundError: No module named 'elftools'
    [4/182] Generating include/generated/kobj-types-enum.h, include/generated/otype-to-str.h, include/generated/otype-to-size.h
    FAILED: zephyr/include/generated/kobj-types-enum.h zephyr/include/generated/otype-to-str.h zephyr/include/generated/otype-to-size.h C:/Users/zephyrproject/zephyr/build/zephyr/include/generated/kobj-types-enum.h C:/Users/zephyrproject/zephyr/build/zephyr/include/generated/otype-to-str.h C:/Users/zephyrproject/zephyr/build/zephyr/include/generated/otype-to-size.h
    cmd.exe /C "cd /D C:\Users\zephyrproject\zephyr\build\zephyr && C:\Users\Administrator\AppData\Local\Programs\Python\Python38\python.exe C:/Users/zephyrproject/zephyr/scripts/build/gen_kobject_list.py --kobj-types-output C:/Users/zephyrproject/zephyr/build/zephyr/include/generated/kobj-types-enum.h --kobj-otype-output C:/Users/zephyrproject/zephyr/build/zephyr/include/generated/otype-to-str.h --kobj-size-output C:/Users/zephyrproject/zephyr/build/zephyr/include/generated/otype-to-size.h --include-subsystem-list C:/Users/zephyrproject/zephyr/build/zephyr/misc/generated/struct_tags.json "
    Traceback (most recent call last):
    File "C:/Users/zephyrproject/zephyr/scripts/build/gen_kobject_list.py", line 62, in <module>
    import elftools
    ModuleNotFoundError: No module named 'elftools'
    [6/182] Generating ../../tfm/CMakeCache.txt
    FAILED: tfm/CMakeCache.txt C:/Users/zephyrproject/zephyr/build/tfm/CMakeCache.txt
    cmd.exe /C "cd /D C:\Users\zephyrproject\zephyr\build\tfm && "C:\Program Files\CMake\bin\cmake.exe" -GNinja -DTFM_TOOLCHAIN_FILE=C:/Users/zephyrproject/modules/tee/tf-m/trusted-firmware-m/toolchain_GNUARM.cmake -DCROSS_COMPILE=C:/Users/zephyr-sdk-0.15.2/arm-zephyr-eabi/bin/arm-zephyr-eabi -DCMAKE_BUILD_TYPE=MinSizeRel -DTFM_PLATFORM=nordic_nrf/nrf9160dk_nrf9160 -DCONFIG_TFM_BUILD_LOG_QUIET=ON -DTFM_LIB_MODEL=OFF -DCONFIG_TFM_SPM_BACKEND="IPC" -DBL2=TRUE -DNS=FALSE -DTFM_ISOLATION_LEVEL=1 -DMCUBOOT_IMAGE_NUMBER=2 -DTFM_EXCEPTION_INFO_DUMP=OFF -DTFM_PARTITION_LOG_LEVEL=TFM_PARTITION_LOG_LEVEL_INFO -DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_INFO -DTFM_PARTITION_PROTECTED_STORAGE=ON -DTFM_PARTITION_INTERNAL_TRUSTED_STORAGE=ON -DTFM_PARTITION_CRYPTO=ON -DTFM_PARTITION_INITIAL_ATTESTATION=ON -DTFM_PARTITION_PLATFORM=ON -DTFM_PARTITION_AUDIT_LOG=OFF -DTFM_PARTITION_FIRMWARE_UPDATE=OFF -DCRYPTO_RNG_MODULE_DISABLED=FALSE -DCRYPTO_KEY_MODULE_DISABLED=FALSE -DCRYPTO_AEAD_MODULE_DISABLED=FALSE -DCRYPTO_MAC_MODULE_DISABLED=FALSE -DCRYPTO_HASH_MODULE_DISABLED=FALSE -DCRYPTO_CIPHER_MODULE_DISABLED=FALSE -DCRYPTO_ASYM_ENCRYPT_MODULE_DISABLED=FALSE -DCRYPTO_ASYM_SIGN_MODULE_DISABLED=FALSE -DCRYPTO_KEY_DERIVATION_MODULE_DISABLED=FALSE -DMCUBOOT_PATH=C:/Users/zephyrproject/bootloader/mcuboot -DCONFIG_TFM_FP=soft -DHAL_NORDIC_PATH=C:/Users/zephyrproject/modules/hal/nordic -DMBEDCRYPTO_PATH=C:/Users/zephyrproject/modules/crypto/mbedtls -DTFM_TEST_REPO_PATH=C:/Users/zephyrproject/modules/tee/tf-m/trusted-firmware-m/../tf-m-tests -DPSA_ARCH_TESTS_PATH=C:/Users/zephyrproject/modules/tee/tf-m/trusted-firmware-m/../psa-arch-tests C:/Users/zephyrproject/modules/tee/tf-m/trusted-firmware-m"
    -- The C compiler identification is GNU 12.1.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/Users/zephyr-sdk-0.15.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    -- Found Python3: C:/Python311/python.exe (found version "3.11.0") found components: Interpreter
    Traceback (most recent call last):
    File "C:\Users\zephyrproject\modules\tee\tf-m\trusted-firmware-m\tools\tfm_parse_manifest_list.py", line 14, in <module>
    from jinja2 import Environment, BaseLoader, select_autoescape, TemplateNotFound
    ModuleNotFoundError: No module named 'jinja2'
    CMake Error at tools/CMakeLists.txt:161 (message):
    File generation failed


    -- Configuring incomplete, errors occurred!
    See also "C:/Users/zephyrproject/zephyr/build/tfm/CMakeFiles/CMakeOutput.log".
    See also "C:/Users/zephyrproject/zephyr/build/tfm/CMakeFiles/CMakeError.log".
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\Program Files\CMake\bin\cmake.EXE' --build 'C:\Users\zephyrproject\zephyr\build'

    C:\Users\zephyrproject\zephyr>

  • Jacek Majda said:
    In view of the above, I am surprised that you stated that "The Blinky sample is NOT designed for the nRF9160".

    Sorry, I mixed this sample with another. You are right, this does support nRF9160 DK

    Jacek Majda said:
    I am using nRF Connect SDK v2.2.99-dev3 and I am able to build the Blinky sample for my build target: nrf9160dk_nrf9160_ns without any problems and without any errors, when I use the nRF Connect SDK v2.2.99-dev3.

    Can you please try with our latest  official tag, v2.2.0? The version you are working on the current main branch, and there might be changes introduces into this version that causes issues. 

    Jacek Majda said:
    -- Zephyr version: 3.2.99 (C:/Users/zephyrproject/zephyr)

    Also, from the log I can see that you also have Zephyr project installed which might cause issues with nRF Connect SDK (which includes Zephyr project). 

  • Hello Oyvind,

    I am still using the nRF Connect SDK v2.2.99-dev3 but I have managed to build the Blinky sample. the hci_lpuart sample and the LTE Sensor Gateway sample using "west build" command, by ensuring that I type this command in the application's root directory i.e. the folder that contains the application's CMakeLists.txt.

    However, when I tried to flash the "build" into my development kit using "west flash" command (from zephyr build directory) I got the following FATAL ERROR:

    FATAL ERROR: one or more Python dependencies were missing; see the getting started guide for details on how to fix it.

    I did paste a copy of the FATAL ERRORS below (in Italic).

    I checked the getting started guide for details on how to fix this problem but I did not find a clear explanation on how to do that.

    How can this problem be fixed?

    Shall I uninstall the Zephyr project to avoid possible issues with nRF Connect SDK (which includes Zephyr project)?

    Regards,

    JM

    C:\Nordic-2299\v2.2.99-dev3\nrf\samples\bluetooth\hci_lpuart>cd.\build

    C:\Nordic-2299\v2.2.99-dev3\nrf\samples\bluetooth\hci_lpuart\build>west flash
    -- west flash: rebuilding
    ninja: no work to do.
    -- west flash: using runner nrfjprog
    FATAL ERROR: one or more Python dependencies were missing; see the getting started guide for details on how to fix

    C:\Nordic-2299\v2.2.99-dev3\nrf\samples\bluetooth\hci_lpuart\build>west flash --runner jlink
    -- west flash: rebuilding
    ninja: no work to do.
    -- west flash: using runner jlink
    FATAL ERROR: one or more Python dependencies were missing; see the getting started guide for details on how to fix

    C:\Nordic-2299\v2.2.99-dev3\nrf\samples\bluetooth\hci_lpuart\build>

Related