nRF Connect for VSCode does not allow python environment?

With conventional python virtual environment and Zephyr west, things seems to work well. I decided to give it a try to nRF Connect for VSCode and I observed that it not use python virtual environment. It just installed west in an arbitrary miniconda environment which i used for other purpose.

Then I tried Guiconfig from Actions, which failed on Windows 11 with "The terminal process failed to launch: Path to shell executable "cmd" is not a file or a symlink". To solve this, I added to User Settings in VS Code the following two lines

"terminal.integrated.defaultProfile.windows": "nRF Connect",
"nrf-connect.kconfig.executeInDefaultShell": true,

After this, Guiconfig failed with incompatible python39.dll. Here I noticed that nRF Connect for VSCode (or the toolchain within) is using an unrelated python environment.

Up until now I couldn't find the way to set the correct python environment for nRF Connect for VSCode. I did "Python: Select Interpreter" and I manually added C:\ncs\toolchains\c3b5ff664\opt\bin\python.exe. When I tried Guiconfig, still used my other python.exe, despite restart.
Then I manually hide conda and other python by removing from the PATH.

After this, I get the error "west" cmdlet not found.

Then i opened a terminal in VSCode and I checked python version, which was 3.12.6. There I installed (again manually) west using pip.

Still doesn't work.

To me seems the root of the problem is that nRF Connect for VSCode doesn't have python venv per workspace or anyhow. Tell me if I am wrong and does exists the possibility to set virtual environment within VSCode or this nRF Connect for VSCode.

  • In Toolchain Manager, SDK Environments, where I see nRF Connect SDK v2.6.2 or v2.7.0 there is a drop-down button which opens a popup menu. There the "Open command prompt" will open a window which looks like would be python virtual environment. It would be nice to know precisely what is that. From there I cd to the workspace folder and start VSCode from that prompt with "code".

    Than Guiconfig works.

    When I try to debug a simple demo app on a nRF52849DK board, it starts step by step but does not reach the main function where I put a breakpoint. Instead is writing me

    cd "c:\ncs\v2.7.0\modules\hal\cmsis\CMSIS\Core\Include\" && gcc cmsis_gcc.h -o cmsis_gcc && "c:\ncs\v2.7.0\modules\hal\cmsis\CMSIS\Core\Include\"cmsis_gcc
    'gcc' is not recognized as an internal or external command,
    operable program or batch file.
    Uhm... I am in Windows 11! 
    I am not sure about how well this toolchain it was tested. Unfortunately I would like to use v2.7.0. Now I will try to install the older one, just to check.
  • Looks like when I types "code" by reflex I typed "code ."  and that caused the problem. Now I can debug also.

Related