Poe script task uses global python path instead of the one in the virtual environment #232
-
pyenv global 3.12
python -V
# 3.12
cd my-project
pyenv local 3.10
poetry install --no-root
python -V
# 3.10 Then I have a simple python script to do the same # version.py
import sys
def echo():
print("Python version:", sys.version)
if __name__ == "__main__":
echo() Then in my tasks file I have [tool.poe.tasks.version]
script = "version:echo" Then when I test it python version.py
# Python version: 3.10.14 ....
python -m version
# Python version: 3.10.14 ....
poe version
# Poe => version
# Python version: 3.12.4 ... How do I get poe to use the version in my local virtual environment? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi @fritz-trawa, thanks for the question. I need some more info to tell whether what you describe is expected behavior or not. If used with poetry then poe will by default use whatever python is referenced in the virtualenv managed by poetry, that is the env returned by Another important question, is the version task defined in the main pyproject.toml file alongside poetry related config or is it imported from another file? If it's an import, does it start working if you move it to the pyproject.toml? If so then we have a bug. This is because poe will only default to using the PoetryExecutor if it detects poetry related config, which should guarantee using the poetry virtualenv (if available). Note that you can also configure poe to use a a specific virtualenv or to have no opinion about it. |
Beta Was this translation helpful? Give feedback.
-
Hi just a heads up to thank you for responding, I'll get back to it after my holidays |
Beta Was this translation helpful? Give feedback.
-
Reopening as the issue is occurring again I have added the task [tool.poe.tasks.wtf]
shell = "poetry env info -p" and [tool.poe.executor]
type = "poetry" And with them ❯ poetry env info -p
/Users/fritz/Library/Caches/pypoetry/virtualenvs/timeseries-hub-scripts-BBfc8S4B-py3.10
❯ poe wtf
/Users/fritz/Library/Caches/pypoetry/virtualenvs/timeseries-hub-Zz_YmjRr-py3.12 3.12 is an old venv, poe for some reason seems to be fixated on using it. Does it cache its settings somewhere? |
Beta Was this translation helpful? Give feedback.
Hi just a heads up to thank you for responding, I'll get back to it after my holidays