Final steps
Ok, you’ve got everything installed.
Now comes the trickest part, but the most important from a quality-of-life perspective.
Testing your installation
You should be able to run these commands from a terminal on any OS.
--version
pyenv 3.12.6
pyenv global python --version
--version
poetry --version
gh --version
git --version
code quarto check
In the final quarto check, verify that jupyter runs and that the python version in quarto matches the python you installed with pyenv.
Coordinating all the tools
To make everyting work properly, our desire is for:
- poetry to shell into the correct virtual environment, and
- quarto to recognize correct version of python for the virtual environments created by poetry.
We do this by storing the correct version of python in the environment of the shell. Each shell (e.g., powershell, zsh and bash) is slightly different but they work about the same.
Each time a terminal window opens the shell executes commands found in a special “run command” file. This approach permits the shell to dynamically adapt to the state of the computer at the time a shell opens.
To get all the programs to smoothly work together we need to add (or verify) that a few commands exist in these run command (or rc) files.
Windows uses several different shells: CMD, powershell and powershell-core. Our preferred shell for this activity is powershell.
Powershell stores it’s run commands in the file: $ENV:USERPROFILE\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
. I know, kill me. BUT, powershell gives the abbreviation $PROFILE to permit easier access.
On some machines, the $PROFILE folder may not yet, so we’ll want to create the folder before we edit the file.
Open a powershell terminal and paste the following command
# Read the folder path from $PROFILE variable
$folderPath = [System.IO.Path]::GetDirectoryName($PROFILE)
# Check if the folder exists and do your thing
if (-not (Test-Path -Path $folderPath -PathType Container)) {
New-Item -Path $folderPath -ItemType Directory
Write-Host "Folder created: $folderPath"
} else {
Write-Host "Folder already exists: $folderPath"
}
Now, let’s edit (or create) the $PROFILE
$profile code
and look for the following commands.
If they don’t exist, paste them to the bottom of the file. If they exists, make sure that those in the $PROFILE match those below.
# These settings disable annoying quarto messages
$env:DENO_NO_UPDATE_CHECK=1 # to warning about deno upgrades
$env:DENO_TLS_CA_STORE="system" # to stop the BAD CERTIFICATE deno warning
$env:PYDEVD_DISABLE_FILE_VALIDATION=1 # for Python 3.11 above, to disable warning message RE: debugging
$env:VIRTUAL_ENV_DISABLE_PROMPT=0 # set to 1 to disable venv prompt change
# This code ensures Quarto finds the correct python from pyenv or poetry if a venv exists.
$env:QUARTO_PYTHON=$(pyenv which python) # to work with pyenv global or local python
$pythonPoetryPath = $(poetry env info -e 2> $null)
if ($pythonPoetryPath -ne $null) {
# extract the venv name from the python poetry path
$venvName = Split-Path -Path $pythonPoetryPath -Parent | Split-Path -Parent | Split-Path -Leaf
Write-Output "QUARTO_PYTHON set to Poetry venv: $venvName"
$env:QUARTO_PYTHON=$var # override with poetry venv python as needed
} else {
Write-Output "QUARTO_PYTHON set to $(pyenv version)"
}
Save the profile, close your shell and reopen your shell.
At the open you should see an appropriate message printed by the code above. This code will be executed every time you open a new terminal or when you run poetry shell.
A mac uses the zsh shell. Configuration commands are stored in the .zshrc file stored in the users home (~) directory.
(add stuff here)
Your linux machine most probably uses the bash shell. Configuration commands are stored in the .bashrc file stored in the users home (~) directory.