zed icon indicating copy to clipboard operation
zed copied to clipboard

Python virtual environment dropdown does not work

Open all-iver opened this issue 7 months ago • 6 comments

Summary

The Python "Select Virtual Environment" dropdown no longer works to configure either the terminal pane or inline pytest runners.

Description

If it matters, I'm using pyenv with python installs in ~/.pyenv/versions. When opening a terminal or running a test using the inline "run" button, the default pyenv python is always used regardless of the selected python version in the dropdown at the bottom right.

Steps to reproduce:

  1. Select a python version in the dropdown in the bottom right
  2. Open the terminal pane to start a new shell
  3. python --version

Expected Behavior: The terminal pane and pytest runners should both use the python virtual environment I selected.

Actual Behavior: They use the default pyenv virtual environment.

I'm not aware of any settings that affect this. It would be nice to have some kind of global setting for the python env used in a project - right now it seems that lsp, terminal and jupyter kernel are all separate. Also there seems to be no way to configure the pytest inline test runners at all, that I can find.

Zed Version and System Specs

Zed: v0.184.8 (Zed) OS: Linux Wayland ubuntu 24.04 Memory: 15.5 GiB Architecture: x86_64 GPU: Intel(R) UHD Graphics 620 (KBL GT2) || Intel open-source Mesa driver || Mesa 24.2.8-1ubuntu1~24.04.1

all-iver avatar May 02 '25 17:05 all-iver

Experiencing a similar issue with conda. After selecting the conda virtual environment, the terminal does not use the correct environment (unless explicitly activated via conda), but more importantly pyright within the editor does not detect the packages present within the environment (I did verify that they are present by activating the virtual environment in the terminal and running pip list)

Hebruwu avatar May 05 '25 22:05 Hebruwu

Observed this with pyenv on MacOS as well w/version 0.184.10. Similar behavior as @Hebruwu reports, that is the pyenv environment is active and I launch zed from that shell using zed --foreground then the editor behaves as if it is in the correct environment, and in any other case it does not ie missing packages etc. The environment/toolchain selector in the UI seems to do nothing in this version when selected.

Our of curiosity and hopes at getting more familiar with this codebase, I git bisected this issue and landed on 456e54b87c being the offending commit... however, given the contents of that commit, I do not understand how it is related.

fredthomsen avatar May 06 '25 04:05 fredthomsen

There is the same issue here. I can't find the package in the selected virtual environment unless I specify a particular environment variable in pyproject.toml.

mrzzmrzz avatar May 07 '25 12:05 mrzzmrzz

Same issue. I am unable to run my python modules using the selected virtual environment.

billylaing avatar May 08 '25 12:05 billylaing

Found a workaround for getting pytest to work again, see my comment here. However, the new agentic AI stuff is also affected by this issue and doesn't run commands in the right python environment.

all-iver avatar May 10 '25 22:05 all-iver

I'm having the same issue, but it took me a while to realise it because I spend most of my time coding remotely. So what's surprising and thought I'd add to this issue is: this does not seem to happen in remote development (linux server, Mac client), but it does happen locally (Mac client / project locally on Mac).

Also it seems like the dropdown does do something which is it does autoactivate the environment in terminal shells (cmd+j) for me. But indeed built-in Pyright does not seem to recognise the virtual environment selected in the dropdown.

For added context I'm using environments created with uv.

rainx0r avatar May 11 '25 21:05 rainx0r

I am also experiencing the same issue. Looks like zed relies on the default python in the system, ignoring whatever you actually select in the UI. I tried using the pyright configuration shown in the zed docs as well as setting the virtual environment path to the projects vence but it does not pick that up either.

sudoish avatar May 18 '25 04:05 sudoish

I have noticed this, it is definitely some kind of a regression. What's also very strange is that configuring the venv + venvPath doesn't do anything anymore in project settings. A lot of people use Python, this seems pretty bad?

demiurg avatar May 22 '25 15:05 demiurg

Related issue: https://github.com/zed-industries/zed/issues/29323

demiurg avatar May 22 '25 15:05 demiurg

Another potentially related issue: https://github.com/zed-industries/zed/issues/20402

demiurg avatar May 22 '25 15:05 demiurg

And another related issue: #27332

demiurg avatar May 22 '25 15:05 demiurg

Could not find the option to select Python Env in the Zed 0.193.3 07/02/2025.
This makes me give up using ZED as the main editor every time I want to try it.

Chuong98CC avatar Jul 09 '25 04:07 Chuong98CC

We've changed a bunch of stuff around Python in 0.201.x. Are y'all still experiencing these issues?

osiewicz avatar Aug 27 '25 20:08 osiewicz

Yeah, the agent does not run in the correct python environment either (I use conda as well) :/

Zed 0.202.7

BTW (OT): haven't tested with the newest version, but in the previous version Zed does not remember which environment has been selected across restarts. I looked in the code and from what I could understand it persist the info, but use a unstable worktree identifier to do so.

olejorgenb avatar Sep 05 '25 09:09 olejorgenb