Problem with "vscode Getting Started" guide: quarto preview is not selecting correct interpreter, incorrectly claims python env is unactivated #5140
-
I am trying to follow the "getting started" guide for quarto with vscode and cannot get the first example to work. This one: https://quarto.org/docs/get-started/hello/vscode.html. I am on a windows 11 machine and manage my python interpreters with pyenv-win. The global default python is 3.11.2.
I have installed quarto-cli and I've captured the output from
I also have vscode. It's already setup for python programming and today I installed the latest quarto extension, I've been using poetry to work with python projects, but I couldn't get it to work with this quarto example. So in order to increase the likelyhood of getting help, I am following the example in getting-started as closely as possible (and temporarily abandoning poetry). In the vscode terminal, I setup my local python with Just as a sanity check, running
Well, that's not right! It says that my Python environment is unactivated but I literally just activated it! Moreover, it doesn't seem to be pointing to my .venv python. It's just pointing to the pyenv global python. Going on to install dependencies anyway (in the activated virtual environment that quarto says is unactivated):
It seems to install, there's a boatload of stuff in .venv/Lib/. But when I try to render, it fails like below, again complaining about unactivated virtual environment, and also saying that jupyter is not available (even though I just added it).
It looks like quarto is not able to detect my python virtual environment? I would really like to use quarto. It seems mostly OK for me in rstudio, and it would be so awesome to use it in vscode + python as well. But I REALLY NEED to use a virtual environment with python stuff. Of course, it would be necessary to get this "out-of-the-box" hello-world example working as well. Does anyone have ideas about what might be going on here and how I can troubleshoot this further? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 11 replies
-
well, I have the same issue here on mac with conda, I tried multiple solutions even the global variable quarto-cli and quarto in VSCode insist on using I couldn't able to solve the issue. I hope someone from the quarto team look into this issue. I'm not sure if @angelotrivelli found a solution for that. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, I still get the same problem even after updating to Quarto To summarize, even after activating my virtual environment with
Quarto preview fails to use the venv python installation (and the libraries I had installed into it like jupyter):
|
Beta Was this translation helpful? Give feedback.
-
Is there a way to just "force" quarto to use the python virtual environment of the directory in which it has been invoked? |
Beta Was this translation helpful? Give feedback.
-
I have the same issue on Linux and VSCode. VSCode terminal (bash) has variable |
Beta Was this translation helpful? Give feedback.
-
I ran into a similar issue with VS Code on MacOS. I use conda for all my environments. Quarto would render with the global interpreter rather than with a specific conda env. I solved it by these steps:
PS: I also had to install jupyter_contrib_extensions to allow for code execution during render of Quarto docs. |
Beta Was this translation helpful? Give feedback.
-
Same issue with Poetry here. I found out that if Poetry creates in-project .venv and this is added to .gitignore, VS Code Python can't find the python .venv! $ poetry config --list | grep virtualenvs.in-project
virtualenvs.in-project = true
$ poetry init
[tool.poetry]
name = "debug_my_venv"
version = "0.1.0"
description = ""
authors = ["..."]
readme = "README.md"
packages = [{include = "debug_my_venv"}]
[tool.poetry.dependencies]
python = "^3.11"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
$ poetry shell
$ poetry install
(.venv/ generated)
$ echo ".venv/" > .gitignore
$ touch foo.py
$ code . Lower right corner of VS Code show that system python interpreter "3.11.4 64-bit" ( "> Python: Select Interpreter" also recommmeds Now, repeat the entire test in a new folder, but without creating .gitignore. The interpeter
|
Beta Was this translation helpful? Give feedback.
First let me give a workaround that could unblock you: You can set the env var
QUARTO_PYTHON
to a specific python version to force Quarto to use that one. It you set the one from your virtual env, I think it should unblock you.That is a workaround I used in the past in the context of this issue with pyenv #1463
It seems different for you as it seems
quarto check
now findpyenv
, but I bet there is an issue in the detection process for virtual environmnent on Windows.So seems like an issue to me and I need to look into it.