GCBallesteros / jupytext.nvim

Jupyter notebooks on neovim powered by Jupytext
88 stars 19 forks source link

Doesn't utilize virtual environment #24

Open lks-k opened 7 months ago

lks-k commented 7 months ago

Currently, jupytext.nvim does not utilize any virtual environment for the jupytext package, even if one is specified using the python3_host_prog option.

Steps to reproduce

With the minimal setup minimal.lua like so:

vim.g.python3_host_prog = vim.fn.fnamemodify("./venv/bin/python3", ":p")

local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
    {
        "GCBallesteros/jupytext.nvim",
        lazy = false,
        config = true,
    },
}
require("lazy").setup(plugins, { root = root .. "/plugins" })

Output of checkhealth

After executing the steps above the output of :checkhealth jupytext is as follows:

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

jupytext.nvim ~
- ERROR Jupytext is not available
  - ADVICE:
    - Install jupytext via `pip install jupytext`

Expected behaviour

The local installation of jupytext inside the environment should be used.

More information

GCBallesteros commented 7 months ago

jupytext.nvim calls jupytext using vim.fn.system(cmd). jupytext must therefore be findable on the PATH which I believe is not the case above. The easiest way to get it on the PATH is by installing it globally. Next easiest is to activate the venv where it is installed prior to opening nvim.

lks-k commented 7 months ago

Oh, I see. It's clear why the setup above didn't work then. I'll make sure jupytext is included in the path. Thanks for your help! Out of curiosity, do you have any plans to incorporate the Python environment into future versions or rather stay as is?

tobievil commented 3 weeks ago

As a workaround, I used pipx to install cli in an isolated environment.

pipx install jupytext