mfussenegger / nvim-dap-python

An extension for nvim-dap, providing default configurations for python and methods to debug individual test methods or classes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is pyenv supported?

predmijat opened this issue · comments

Hi,

I've installed both nvim-dap and nvim-dap-python:

use 'mfussenegger/nvim-dap'
use 'mfussenegger/nvim-dap-python'

debugpy is installed in a separate pyenv - ~/.pyenv/versions/dap/bin/python.

When I open main.py of some Python project while being in a directory where pyenv is recognized/activated (and I can run python main.py and it will all work) and run :lua require'dap'.toggle_breakpoint()<cr> I see the prompt where I choose 1: Launch file, it will fail on importing first library that is not in standard lib (but is installed with pip) - it seems that dap didn't recognized the virtualenv created with pyenv.

Let me know if any other info is needed.

Thanks!

nvim-dap-python only recognizes the VIRTUAL_ENV and CONDA_PREFIX environment variables. You need to activate the virtual env up-front before starting neovim for it to get recognized.

Considering I have pyrightconfig.json in the project directory which has info on venvPath and venv, solved with this zsh function:

function vv() {
    venv_path=$(rg venvPath pyrightconfig.json | awk '{print $NF}' | tr -d '"')
    venv=$(rg "venv\"" pyrightconfig.json | awk '{print $NF}' | tr -d '"' | tr -d ',')
    export VIRTUAL_ENV="${venv_path}/${venv}"
    nvim
}

Added a way to customize the logic: #70