Closed tianyouzeng closed 6 months ago
Thank you! Let me have a look this weekend to make sure it doesn't break anything, and then we merge it in. :)
Looks good to me, merging. Thanks for fixing this!
This bug appears again. @linux-cultist @tianyouzeng
{
"linux-cultist/venv-selector.nvim",
dependencies = { "neovim/nvim-lspconfig", "nvim-telescope/telescope.nvim", "mfussenegger/nvim-dap-python" },
opts = {
-- Your options go here
-- name = "venv",
auto_refresh = false,
anaconda_base_path = "D:\\Software\\anaconda3",
anaconda_envs_path = "D:\\Software\\anaconda3\\envs",
},
lazy = true,
event = "VeryLazy", -- Optional: needed only if you want to type `:VenvSelect` without a keymapping
keys = {
-- Keymap to open VenvSelector to pick a venv.
{ "<leader>vs", "<cmd>VenvSelect<cr>", desc = "Select Python Venv" },
-- Keymap to retrieve the venv from a cache (the one previously used for the same project directory).
{ "<leader>vc", "<cmd>VenvSelectCached<cr>", desc = "Select Python Venv(Cached)" },
},
},
The correct path is anaconda\python.exe instead of anaconda\Scripts\python.exe on the Windows side for Anaconda.
This PR fixes a bug for Windows users with conda environments.
The plugin originally sets the environment variable
$VIRTUAL_ENV
when activating virtual environments. This variable is used bynvim-dap-python
to set the Python interpreter path for debugging. However, the relative path of python interpreter for Windows conda environments is[venv]\python.exe
, which is different from other types virtual environments, whose relative path is[venv]\Scripts\python.exe
. Thus setting$VIRTUAL_ENV
leads to a wrong python path (namely[venv]\Scripts\python.exe
) fornvim-dap-python
. This can also be seen from the code ofnvim-dap-python
plugin:Therefore, it seems necessary to set
$CONDA_PREFIX
instead of$VIRTUAL_ENV
when activating conda environments on Windows.This PR fixes the above issue. It does not introduce any changes to non-Windows users.