Quarto fails to recognize Python virtual environment #11257
Unanswered
aronvandepol
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
I have recently switched to astral UV to manage python for me. I have tried to make it work nicely with Quarto and setup a testing script to do this. I create a virtual env with UV that my quarto project will use. this is located at .venv dir next to the quarto qmd file.
I manually install jupyter using
uv pip install jupyter
to ensure the venv can work with quarto.I have tried the following configs to make quarto pick this up:
quarto render
results in a 'There is an unactivated Python environment in .venv. Did you forget to activate it?' error. Alongside the fact that the packages weren't installed.I then adjusted the _quarto.yml
this calls the prerender script:
export QUARTO_PYTHON=.venv/bin/python
calling
quarto render
with this still results in it not using the environment.I then came across the _environtment file which i tried to setup.
_environment
Again, we get the same error that the python venv is not being used.
When in my terminal I source the venv directly using
source ./venv/bin/activate
and runquarto render
still the same error occurs.Only when i call"
export QUARTO_PYTHON=.venv/bin/python
directly before runningquarto render
will the test file run. The necessary packages get installed first through!uv pip install pandas torch
and the code and renders into a html file without errors.My question is if there is a different way, preferably through Quarto, either the project _quarto.yml or the _environment file to set this? Perhaps I am doing something wrong? The idea is that I don't have to call
export QUARTO_PYTHON=.venv/bin/python
in my terminal everytime before rendering.Any help is appreciated!
Beta Was this translation helpful? Give feedback.
All reactions