Re: Zephyr escaping its virtual environment


Bolivar, Marti
 

Hi,

It's hard to diagnose issues like this remotely, and especially with so
few details.

If you are looking for general advice:

- check your PATH for where west is installed
- check things like 'py -3 -m pip freeze' inside and outside
your virtual environment to check what is installed where
- uninstall any pythons on your system, making sure you do not have
'west' on your PATH, then reinstalling them

Using Zephyr with a python virtual environment is supported, does work,
and is my strong personal recommendation. Unfortunately, if you have
been inconsistent about using venvs, it can leave your system in a mixed
state that you will need to untangle.

I have been pushing for virtual environments to be the default
recommendation in the getting started guide for years, but other
maintainers have disagreed with me, and it hasn't happened. Sorry for
any inconvenience.

Marti

On Fri, Nov 12 2021, Jason Bens wrote:
Hey Marti,

As far as I can tell, I don't have west currently installed outside of the virtual environment. This project I'm trying to get going predates a tonne of build environment issues I've been fixing for the past couple weeks, though. When I first started, there was no venv, and python was on the normal windows path. Could it be that the original path has been stored somewhere and survived the purge?

Jason


-----Original Message-----
From: Bolivar, Marti <Marti.Bolivar@nordicsemi.no>
Sent: Thursday, November 11, 2021 6:40 PM
To: Jason Bens <Jason.Bens@teufel.de>; users@lists.zephyrproject.org
Subject: Re: [Zephyr-users] Zephyr escaping its virtual environment

External Email:

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.