Re: Zephyr escaping its virtual environment


Bolivar, Marti
 

Hi, I use zephyr exclusively within virtual environments.

Did you install west outside of the venv? If you build with west, Zephyr
tries to use the same python from the build system that you used for
running west.

On Thu, Nov 11 2021, Jason Bens via lists zephyrproject org wrote:
Hi.

I’m trying to build zephyr inside a python virtual environment. It looks like it’s somehow pulling in the base python interpreter, rather than the fake one provided in the virtual environment. This manifests as zephyr\scripts\dts\python-devicetree\src\devicetree\edtlib.py failing to import yaml (my base python environment is pretty barebones). It looks like the python path is picked up in python.cmake:

foreach(PYTHON_PREFER ${PYTHON_PREFER} ${WEST_PYTHON} "python" "python3")
find_program(PYTHON_PREFER_EXECUTABLE ${PYTHON_PREFER})
if(PYTHON_PREFER_EXECUTABLE) <…snip>

I haven’t defined PYTHON_PREFER or WEST_PYTHON, and don’t see any documentation suggesting I ought to. I don’t fully understand how find_program is finding the executable, but had assumed it would check my path at some point. I’ve confirmed that .venv\Scripts is the first entry in my path. `where python´ from my virtual environment returns the following:

C:\Users\<name>\Projects\<project_name>\.venv\Scripts\python.exe
C:\Users\<name>\AppData\Local\Programs\Python\Python39\python.exe

I’m working with version 2.6.99. Before I file it as an issue, is this something that is fixed in 2.7.99? Is there some known configuration stuff I’m failing to do?

Thanks,


* Jason


Join users@lists.zephyrproject.org to automatically receive all group messages.