Open kamransoomro84 opened 3 months ago
Neovim's integrated terminal, which is used in to run quarto preview
(https://neovim.io/doc/user/various.html#%3Aterminal), does so inside of your default shell. If you have allowed conda
to modify the startup of your default shell, e.g. your bashrc, zshrc or fishrc file, to automatically activate the base environment on startup it will do so and change the available python.
You can add auto_activate_base: false
to your .condarc
file or disable conda entirely by removing the eval "$($CONDA_PREFIX/bin/conda shell.bash hook)"
line from your bashrc.
Does the plugin require r to be installed even if I'm not using it in my qmd file?
No, quarto-cli can be installed independently of R (https://quarto.org/)
I'm still getting the error after uninstalling conda:
Starting python3 kernel...Traceback (most recent call last):
File "/Applications/quarto/share/jupyter/jupyter.py", line 21, in <module>
from notebook import notebook_execute, RestartKernel
File "/Applications/quarto/share/jupyter/notebook.py", line 15, in <module>
from yaml import safe_load as parse_string
ModuleNotFoundError: No module named 'yaml'
Python 3 installation:
Version: 3.12.4
Path: /opt/homebrew/opt/python@3.12/bin/python3.12
Jupyter: (None)
Jupyter is not available in this Python installation.
Install with python3 -m pip install jupyter
I can confirm that my custom environment is activated when I start nvim.
Just to be clear this is not by custom environment. How do I get the plugin to use it?
Does quarto preview
use the correct environment when you call it directly?
And do you have jupyter in your environment?
Yes to both questions. I have been using the custom environment with quarto in vscode. I guess as a work around I can launch quarto preview from the terminal and use the plugin that way but it would be nice to have the neovim command working.
Is there a difference between quarto check
outside of nvim and :tabedit term://quarto check
from nvim?
Yes. Outside of nvim the command locates my venv python. Within neovim it locates my default python. In both cases the python environment was first activated. I think this might be the issue.
I can confirm that if I open a neovim terminal, activate the environment and run quarto preview, it works.
right, so in this case, after disabling conda, it is the binaries from brew
that get added to the path again when the rc file is sourced again from inside of nvim. Can you design your rc file in such a way that it doesn't do that?
I'll have to think about how that can be done. The method suggested in the reddit post of using $SHLVL doesn't work. In my case SHLVL is 1 both within and without nvim.
For example, the proposed solution in the reddit post of using $SHLVL
seems rather elegant.
oh
Also I'm using fish not bash.
I just compared my $PATH variable within and without nvim, with the virtual environment activated in both cases.
It actually doesn't add on the brew
path in nvim. It only adds on its local mason
bin path. The venv
path is still the second path in my $PATH.
Weirdly, if I run :tabedit term://which python
it correctly locates my venv
python. But if I run :tabedit quarto check
it shows my default brew
python.
I have two issues. I have setup my quarto configuration by copying quarto.lua from the kickstarter configuration. When I run QuartoPreview I get the following error:
The other issue is that the plugin appears to be using the wrong python environment. I have a custom environment in
venv
that I activate before starting nvim. But when I quite nvim I get a bunch of error messages like this:This is the wrong python environment but I cannot figure out how to get it to use the right one.
EDIT: I should mention that I am on Mac.