### Bug description

**Background**

When I render documents with Python code chunks the incorrect python interpreter is being used. I would like quarto to execute the code chunks using my virtual environment, but instead it is using a different python interpreter.

**System details**

- Quarto: 1.1.113
- Operating System: M1 mac, macOS Monterey 12.6

**Reprex**

Create and activate a virtual environment:

```bash
python -m venv .venv
source .venv/bin/activate
which python
# /Users/samedwardes/tmp/quarto-env-reprex/.venv/bin/python
python -m pip install jupyter
```

Check quarto:

```bash
quarto check
# [✓] Checking Quarto installation......OK
#       Version: 1.1.113
#       Path: /Applications/quarto/bin
# 
# [✓] Checking basic markdown render....OK
# 
# [✓] Checking Python 3 installation....OK
#       Version: 3.10.4
#       Path: /Users/samedwardes/tmp/quarto-env-reprex/.venv/bin/python3
#       Jupyter: 4.11.1
#       Kernels: python3, connectapi-kernel, my-project-kernel, connectapi
# 
# [✓] Checking Jupyter engine render....OK
# 
# [✓] Checking R installation...........OK
#       Version: 4.2.1
#       Path: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources
#       LibPaths:
#         - /Users/samedwardes/Library/R/arm64/4.2/library
#         - /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library
#       rmarkdown: 2.16
# 
# [✓] Checking Knitr engine render......OK
```

Create a new document `example.qmd`:

````markdown
---
title: Virtual environment
---

Python code chunk:

```{python}
import sys

print(sys.executable)
```
````

Then render it:

```bash
quarto render example.qmd --output - 
# Executing 'example.ipynb'
#   Cell 1/1...Done
# 
# pandoc --output /var/folders/v9/fyndz9rs2hs34xwbs1rtmqtm0000gn/T/quarto-session0e5cab67/6e2ffbde/35950ad9.md
#   to: markdown
#   standalone: true
#   default-image-extension: png
#   
# metadata
#   title: Virtual environment
#   
# ---
# title: Virtual environment
# toc-title: Table of contents
# ---
# 
# Python code chunk:
# 
# ::: {.cell execution_count="1"}
# ``` {.python .cell-code}
# import sys
# 
# print(sys.executable)
# ```
# 
# ::: {.cell-output .cell-output-stdout}
#     /Users/samedwardes/.virtualenvs/py3912/bin/python
# :::
# :::
```

As you can see in the example above, `sys.executable` returns `/Users/samedwardes/.virtualenvs/py3912/bin/python` as opposed to `/Users/samedwardes/tmp/quarto-env-reprex/.venv/bin/python` which is what I was expecting.

**related issues**

- https://github.com/quarto-dev/quarto-web/pull/431

### Checklist

- [X] Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] Please [format your issue](https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us) so it is easier for us to read the bug report.
- [X] Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] Please document the operating system you're running. If on Linux, please provide the specific distribution.
cderv
2022-10-11T19:18:57Z
SamEdwardes
bug needs-repro windows
v1.3
closed
Quarto not using python interpreter from virtual environment
https://github.com/quarto-dev/quarto-cli/issues/2801