Improve Python detection on windows to support virtualenv activated
@cderv is already working on this.
Since Feb 10, 2025.
Assessment
This issue has not been assessed yet.
Description
Currently on Windows, Quarto detection relies on
QUARTO_PYTHONbeing set- The
py.exelauncher being available (with optionallyPY_PYTHONbeing set) condabeing used
However, in situation where pyenv is used to manage python install, or even uv nowadays, it creates problem. All the more because virtual env is not even taken into account at this step of detection
https://github.com/quarto-dev/quarto-cli/blob/ca0587692627150b5693113a89b6ce745b95b0c6/src/command/check/check.ts#L335-L337
cd $env:TEMP
mkdir quarto
cd quarto
uv has some python installed
❯ uv python find
C:\Users\chris\AppData\Roaming\uv\python\cpython-3.13.1-windows-x86_64-none\python.exe
Let's initialize a project with Python 3.13.1
uv init --python 3.13.1
uv add jupyter
Now the version of python for the project is the one from the venv
❯ uv python find
C:\Users\chris\AppData\Local\Temp\quarto\.venv\Scripts\python.exe
But Quarto find none
❯ uv run quarto check jupyter
Quarto 1.7.13
[>] Checking Python 3 installation....(None)
Unable to locate an installed version of Python 3.
Install Python 3 from https://www.python.org/downloads/
Activating virtualenv puts the python binary on PATH
❯ .\.venv\Scripts\activate
❯ (gcm python).Source
C:\Users\chris\AppData\Local\Temp\quarto\.venv/Scripts\python.exe
But still quarto can't find it
❯ quarto check jupyter
Quarto 99.9.9
[>] Checking Python 3 installation....(None)
Unable to locate an installed version of Python 3.
Install Python 3 from https://www.python.org/downloads/
This is because
VIRTUAL_ENVenv var is not check at detection step but later for kernel spec information- windows has
python.exeon PATH and notpython3.exeand dectection code does not account for that.
If py.exe was available then it would work.
❯ cd C:\Users\chris\AppData\Local\Temp\quarto
❯ py -0
No installed Pythons found!
❯ .\.venv\Scripts\activate
❯ py -0
* Active venv
❯ quarto check jupyter
Quarto 99.9.9
[>] Checking Python 3 installation....OK
Version: 3.13.1
Path: C:/Users/chris/AppData/Local/Temp/quarto/.venv/Scripts/python.exe
Jupyter: 5.7.2
Kernels: python3, julia-1.11
[>] Checking Jupyter engine render....OK
So current situation on windows does rely too much on py.exe which is only available for user using Windows Store Python version, or installing from the Python official website.
Related to
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from quarto-dev/quarto-cli
-
binder bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
quarto-dev/quarto-cli#14907 · 3 comments ·
-
brand bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
quarto-dev/quarto-cli#14891 ·
-
brand bug html revealjs
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
quarto-dev/quarto-cli#14882 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
quarto-dev/quarto-cli#14875 ·
-
Percent scripts: accept raw-string (r""") and '''-delimited markdown cells, as jupytext writes them Openengines-jupyter enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
quarto-dev/quarto-cli#14850 · 2 comments ·
All issues in quarto-dev/quarto-cli
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
babalae/bettergi-scripts-list#3674 ·
-
ecosystem wording
Difficulty 1/5 Under an hour Newbie friendliness 90/100
matrix-org/matrix.org#3649 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
vadimdemedes/ink#1029 ·
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·