jupytext.nvim icon indicating copy to clipboard operation
jupytext.nvim copied to clipboard

Doesn't utilize virtual environment

Open theafox opened this issue 1 year ago • 3 comments

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

  • Setup a virtual environment: python3 -m venv venv,
  • install jupytext in this environment (but not globally): venv/bin/python -m pip install pynvim jupytext,
  • run the minimal config given below: nvim -nu minimal.lua, and
  • run :checkhealth jupytext inside Neovim.

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

  • OS: macOS Sonoma 14.4.1
  • Neovim version:
    $ nvim --version
    NVIM v0.9.5
    Build type: Release
    LuaJIT 2.1.1710088188
    

theafox avatar Apr 13 '24 12:04 theafox

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.

GCBallesteros avatar Apr 13 '24 14:04 GCBallesteros

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?

theafox avatar Apr 16 '24 00:04 theafox

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

pipx install jupytext

tobievil avatar Nov 02 '24 08:11 tobievil