Python segment does not activate/show outside Python folders #6004
Unanswered
lnlp
asked this question in
Troubleshoot
Replies: 1 comment 3 replies
-
Additional information: On a different computer (at totally different location) the issue does not occur. Versions tested: |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Code of Conduct
What happened?
I was experimenting with the Python segment and it did not work as expected.
To my understanding .Venv is defined when a virtual environment (venv) has been activated and it will have the value of environment variable VIRTUAL_VENV_PROMPT.
When display_mode is set to always I expect the segment to always be shown. But it does not always, even when a venv is activated.
When I activate a venv from outside of any 'Python folders' then the segment is not shown. When I then make a 'recognized Python folder' my current directory (e.g. folder "venv") then the segment gets displayed and stays displayed even when I move out of that 'Python folder' again. The segment is not shown unless triggered by some other rule than {{ if .Venv }}. Once displayed it appears to behave as expected.
Here is my Python segment code (I tried both below templates (one currently commented out) and the default template. All experience the same issue):
The
above is a nerdfont Python symbol.Example directory structure:
myvenv
contains the virtual environment.I activate it with
source\python\venv\myenv\Scripts\Activate.ps1
(the path before source is omitted here).When
source
is my current directory when I activatemyvenv
with aboveActivate.ps1
script then the Python segment is not shown. When I then change my current directory tovenv
the segment suddenly is displayed. When I then change current directory tosource
again the segment is still displayed.The Python segment should be shown, independent of from within which folder I activate a venv.
Versions tested:
Oh My Posh 24.11.4
PowerShell 7.4.6
Python 3.13.1
Windows 10 22H2
Theme
My own custom theme.
What OS are you seeing the problem on?
Windows
Which shell are you using?
powershell
Log output
Beta Was this translation helpful? Give feedback.
All reactions