Skip to content

doc: 'develop/getting_started/index' jsonschema exception #103697

@aw-engineer

Description

@aw-engineer

Describe the bug

the 'getting started' procedure results in a python exception at step west packages pip --install. Observed with ubuntu focal and debian trixie. Failure after 30 minutes on a moderate speed internet connection.

Workaround: pip install jsonschema prior to west packages pip --install

  1. west dynamically loads zephyr/scripts/west_commands/packages.py
  2. zephyr/scripts/west_commands/packages.py imports zephyr_module
  3. zephyr/scripts/zephyr_module.py imports jsonschema
$ west packages pip --install
...
ZephyrUnittest (/home/user/zephyrproject/zephyr/share/zephyrunittest-package/cmake)
has been added to the user package registry in:
~/.cmake/packages/ZephyrUnittest

Traceback (most recent call last):
  File "/home/user/zephyrproject/.venv/lib/python3.13/site-packages/west/commands.py", line 565, in __call__
    mod = _commands_module_from_file(self.py_file)
  File "/home/user/zephyrproject/.venv/lib/python3.13/site-packages/west/commands.py", line 718, in _commands_module_from_file
    spec.loader.exec_module(mod)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/user/zephyrproject/zephyr/scripts/west_commands/packages.py", line 20, in <module>
    import zephyr_module
  File "/home/user/zephyrproject/zephyr/scripts/zephyr_module.py", line 27, in <module>
    import jsonschema
ModuleNotFoundError: No module named 'jsonschema'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/zephyrproject/.venv/lib/python3.13/site-packages/west/app/main.py", line 584, in run_command
    self.run_extension(args.command, argv)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/home/user/zephyrproject/.venv/lib/python3.13/site-packages/west/app/main.py", line 708, in run_extension
    self.cmd = self.extensions[name].factory()
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/user/zephyrproject/.venv/lib/python3.13/site-packages/west/commands.py", line 567, in __call__
    raise ExtensionCommandError(
        hint=f'could not import {self.py_file}') from ie
west.commands.ExtensionCommandError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/zephyrproject/.venv/bin/west", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/user/zephyrproject/.venv/lib/python3.13/site-packages/west/app/main.py", line 1199, in main
    app.run(argv or sys.argv[1:])
    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/zephyrproject/.venv/lib/python3.13/site-packages/west/app/main.py", line 278, in run
    self.run_command(argv, early_args)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/user/zephyrproject/.venv/lib/python3.13/site-packages/west/app/main.py", line 628, in run_command
    self.handle_extension_command_error(ece)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/home/user/zephyrproject/.venv/lib/python3.13/site-packages/west/app/main.py", line 454, in handle_extension_command_error
    self.cmd.err(msg, fatal=True)
    ^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'err'

Regression

  • This is a regression.

Steps to reproduce

#!/bin/bash
set -e

sudo apt update
sudo apt upgrade
sudo apt install -y --no-install-recommends git cmake ninja-build gperf   ccache dfu-util device-tree-compiler wget python3-dev python3-venv python3-tk   xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1

# Get Zephyr and install Python dependencies
python3 -m venv ~/zephyrproject/.venv
#!/bin/bash
set -ex
source ~/zephyrproject/.venv/bin/activate
pip install west
west init ~/zephyrproject
cd ~/zephyrproject
west update 
west zephyr-export
west packages pip --install

# Install the Zephyr SDK
cd ~/zephyrproject/zephyr
west sdk install

Relevant log output

Impact

Annoyance – Minor irritation; no significant impact on usability or functionality.

Environment

  • Page: develop/getting_started/index
  • Version: main
  • SHA-1: 571831a

Additional Context

This issue was reported from the online documentation page using the 'Report an issue' button.

Metadata

Metadata

Assignees

Labels

area: WestWest utilitybugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions