ModuleNotFoundError: No module named 'torizon_templates_utils'

After creating a fresh/vanilla Torizon project using the VSCode Torizon IDE Extension and selecting the Python template, the tasks run-torizon-binfmt and run-share-wsl-ports fail both because of this error: ModuleNotFoundError: No module named 'torizon_templates_utils'. In more detail:

 *  Executing task: xonsh /home/hp/mwe/.conf/run-container-if-not-exists.xsh --container-runtime docker --run-arguments "--rm --privileged torizon/binfmt:latest" --container-name binfmt 

xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/home/hp/mwe/.conf/run-container-if-not-exists.xsh", line 24, in <module>
    from torizon_templates_utils.errors import Error,Error_Out,last_return_code
    
ModuleNotFoundError: No module named 'torizon_templates_utils'

 *  The terminal process "xonsh '/home/hp/mwe/.conf/run-container-if-not-exists.xsh', '--container-runtime', 'docker', '--run-arguments', '"--rm --privileged torizon/binfmt:latest"', '--container-name', 'binfmt'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 
 *  Executing task: xonsh /home/hp/mwe/.conf/share-wsl-ports.xsh /home/hp/mwe 

xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/home/hp/mwe/.conf/share-wsl-ports.xsh", line 21, in <module>
    from torizon_templates_utils.errors import Error,Error_Out,last_return_code
    
ModuleNotFoundError: No module named 'torizon_templates_utils'

 *  The terminal process "/usr/bin/zsh '-c', 'xonsh /home/hp/mwe/.conf/share-wsl-ports.xsh /home/hp/mwe'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

Even the task check-deps fails for the same reason:

xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/home/hp/mwe/.conf/check-deps.xsh", line 24, in <module>
    from torizon_templates_utils.errors import Error,Error_Out,last_return_code
    
ModuleNotFoundError: No module named 'torizon_templates_utils'

 *  The terminal process "xonsh '/home/hp/mwe/.conf/check-deps.xsh'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

Adding the Pip package torizon-templates-utils to all three files requirements-{debug, local, release}.txt does not fix the problem. What to do?


Torizon IDE Extension version: 3.0.4
VSCode version: 1.99.3
OS: Ubuntu 24.04

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello! Thank you for your detailed description. This issue is related to a recent migration in the Torizon IDE Extension from PowerShell scripts to Python/Xonsh scripts, which brings new dependencies like the Python module torizon_templates_utils. The error you see indicates that your extension setup is missing some of these updated components.

To resolve this, please do the following steps:

  1. Install the Pre-release Version of the Extension

    The latest templates and corresponding dependencies are available in the pre-release version of the Torizon IDE Extension. Please install or switch to the pre-release version by following the instructions here:
    Pre-Release Torizon OS 7 Support / VS Code / Torizon Templates / Development Tools

  2. Configure VS Code to Use the ‘dev’ Branch for Templates

    Update your VS Code global settings (open Command Palette > Preferences: Open Settings (JSON)) and add the following lines:

    "torizon.templatesRepo": "https://github.com/torizon/vscode-torizon-templates",
    "torizon.templatesBranch": "dev",
    "torizon.templatesTag": "dev",
    

    This ensures you’re using the development branch, which includes the necessary Python/Xonsh dependencies.

  3. Restart VS Code

    Close and reopen VS Code to ensure all changes take effect.

These steps should pull the latest scripts and dependencies, resolving the missing torizon_templates_utils error and allowing your project tasks (like run-torizon-binfmt and check-deps) to run correctly.

For further reference, please see:

Best regards, Toradex AI Assistant.

Unfortunately, the problems still persist after switching to the pre-release version and adding the mentioned settings. I’ll switch back to the stable channel again.

Hey @ypo

Could you please check the following command on your terminal:

whereis xonsh

The IDE extension runs a installation check on the initialization and expects to have the xonsh and dependencies under pipx virtual environment. So, if you had installed it by pip or by apt this will fail.

Let me know,

As you’ve suggested, I removed xonsh that was previously installed via apt and installed it via pipx. The command whereis xonsh now confirms

➜  ~ whereis xonsh
xonsh: /home/hp/.local/bin/xonsh

if issued from my regular zsh terminal. However, after restarting VSCode, the share-wsl-ports task gives this error:

 *  Executing task: xonsh /home/hp/mwe/.conf/share-wsl-ports.xsh /home/hp/mwe 

zsh:1: command not found: xonsh

 *  The terminal process "/usr/bin/zsh '-c', 'xonsh /home/hp/mwe/.conf/share-wsl-ports.xsh /home/hp/mwe'" failed to launch (exit code: 127). 
 *  Terminal will be reused by tasks, press any key to close it.

Interestingly, if I issue the command /usr/bin/zsh -c xonsh /home/hp/mwe/.conf/share-wsl-ports.xsh /home/hp/mwe directly from a plain zsh terminal (not via VSCode task), it runs without any error. Could it be, that VScode somehow uses a different shell, if executing tasks … or at least a different environment than a plain zsh shell does?

By the way: Has pipx ever been mentioned in the docs? Your answer is the first time I stumble upon that program in the toradex context.

pipx is not mentioned because it should be set up automatically.
As you mentioned zsh, I see that maybe you will have some issues, not only with the setup, if the zsh is set as your login shell. So, I would recommend you to set bash as your login shell and then call the zsh from bash. For example: vscode-torizon-templates/scripts/bash/setup-xonsh.sh at dev · torizon/vscode-torizon-templates the path for the xonsh is added on the .bashrc. Also C/C++ debug under VS Code only works under bash and other possible issues.

Apparently, switching back to bash and freshly installing the Torizon extension resolved my issues!

1 Like

Hi @ypo!

Glad to know that this is now solved for you!

Thanks for the feedback and for marking the solution! Very helpful :smiley:

Have a nice day!