Skip to content

How to automatically use a conda environment? #42

@spring-haru

Description

@spring-haru

I am trying to automatically set a conda environment if a .py file is opened. I wonder if you can help me out. I tried the following

return  {
  "HallerPatrick/py_lsp.nvim",
  config = function()
    require('py_lsp').setup{
      opts = {
        host_python = "~/opt/anaconda3/envs/py12/bin",
        auto_source = true,
        language_server = "pyright",
        source_strategies = "conda",   -- "default", "poetry", "conda", "system",
        default_venv_name = "py12"
      }
    }
  end,
}

but it returns

Could not retrieve python path, try :PyLspReloadVenv

Then, if I do :PyLspActivateCondaEnv, then the cond environment is used in lsp, though :checkhealth shows

py_lsp: require("py_lsp.health").check()

py_lsp.nvim Report ~
- ERROR No client attached
- ERROR Setup is incorrect

How am I supposed to change the code to automatically set the conda environment. Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions