quarto-dev / quarto-dev/quarto-cli

Support other python on Windows than py.exe supported ones (like pyenv)

Open
#1,463 4 comments 1 reaction 1 assignee View on GitHub

@cderv is already working on this.

Since Jan 9, 2023.

enhancement python-setup windows
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

Bug description

Currently, using Python and Quarto supposes that py.exe is used.
First Python is check on windows with py launcher if PY_PYTHON is set
https://github.com/quarto-dev/quarto-cli/blob/e13e08c7e0036f42b6e3e1f77ad16ef1d4d20ff5/src/core/jupyter/capabilities.ts#L34-L37

But also a second time if conda not found
https://github.com/quarto-dev/quarto-cli/blob/e13e08c7e0036f42b6e3e1f77ad16ef1d4d20ff5/src/core/jupyter/capabilities.ts#L44-L51

Using pyenv on windows (https://pyenv-win.github.io/pyenv-win/) will not register python version in registry so py.exe will not found it.

Here is my setup

> py --list
Installed Pythons found by C:\Windows\py.exe Launcher for Windows
No Installed Pythons Found!

> pyenv versions
* 3.9.13 (set by C:\Users\chris\scoop\apps\pyenv\current\pyenv-win\version)

> quarto check jupyter

[>] Checking Python 3 installation....(None)

      Unable to locate an installed version of Python 3.
      Install Python 3 from https://www.python.org/downloads/

> (Get-Command python3).Path
C:\Users\chris\scoop\apps\pyenv\current\pyenv-win\shims\python3.bat

> python3 C:\Users\chris\Documents\DEV_R\quarto-cli\src\resources\capabilities\jupyter.py
versionMajor: 3
versionMinor: 9
versionPatch: 13
versionStr: "3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)]"
conda: false
execPrefix: "C:/Users/chris/scoop/apps/pyenv/current/pyenv-win/versions/3.9.13"
executable: "C:/Users/chris/scoop/apps/pyenv/current/pyenv-win/versions/3.9.13/python3.exe"
jupyter_core: 4.11.1
nbformat: 5.4.0
nbclient: 0.6.6
ipykernel: 6.15.1

So for now quarto does not find Python because py.exe does not find it.

Current workaround is to set QUARTO_PYTHON

$env:QUARTO_PYTHON=$(pyenv which python3)

Then

> quarto check jupyter

[>] Checking Python 3 installation....OK
      Version: 3.9.13
      Path: C:/Users/chris/scoop/apps/pyenv/current/pyenv-win/versions/3.9.13/python3.exe
      Jupyter: 4.11.1
      Kernels: bash, julia-1.7, python3

[>] Checking Jupyter engine render....OK

I think it would be helpful to bring better support to pyenv for windows inside Quarto.

As a side note, this below does not found python binary on windows even if in PATH
https://github.com/quarto-dev/quarto-cli/blob/e13e08c7e0036f42b6e3e1f77ad16ef1d4d20ff5/src/core/jupyter/capabilities.ts#L41-L42

because of Deno limitation on Windows (same as tinytex fixes) and requireQuoting() with safeWindowsExec() is required to make it work.

This would however prevent finding python3 which is looked after.

Anyway, I think there is some improvement to do here for Windows user experience.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.