Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error E79 when running QuartoPreview and wrong Python being used #143

Open
kamransoomro84 opened this issue Aug 6, 2024 · 19 comments
Open

Comments

@kamransoomro84
Copy link

kamransoomro84 commented Aug 6, 2024

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:

E79: Cannot expand wildcards

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:

Starting python3 kernel...Traceback (most recent call last):
    3   File "/Applications/quarto/share/jupyter/jupyter.py", line 21, in <module>
    4     from notebook import notebook_execute, RestartKernel
    5   File "/Applications/quarto/share/jupyter/notebook.py", line 15, in <module>
    6     from yaml import safe_load as parse_string
    7 ModuleNotFoundError: No module named 'yaml'
    8 Python 3 installation:
    9   Version: 3.10.12 (Conda)
   10   Path: /opt/homebrew/Caskroom/mambaforge/base/bin/python
   11   Jupyter: (None)
   12
   13 Jupyter is not available in this Python installation.
   14 Install with conda install jupyter

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.

@jmbuhr
Copy link
Collaborator

jmbuhr commented Aug 9, 2024

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.

@jmbuhr
Copy link
Collaborator

jmbuhr commented Aug 9, 2024

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.

@kamransoomro84
Copy link
Author

Does the plugin require r to be installed even if I'm not using it in my qmd file?

@jmbuhr
Copy link
Collaborator

jmbuhr commented Aug 9, 2024

No, quarto-cli can be installed independently of R (https://quarto.org/)

@kamransoomro84
Copy link
Author

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/[email protected]/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.

@kamransoomro84
Copy link
Author

Just to be clear this is not by custom environment. How do I get the plugin to use it?

@jmbuhr
Copy link
Collaborator

jmbuhr commented Aug 9, 2024

Does quarto preview use the correct environment when you call it directly?

@jmbuhr
Copy link
Collaborator

jmbuhr commented Aug 9, 2024

And do you have jupyter in your environment?

@kamransoomro84
Copy link
Author

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.

@jmbuhr
Copy link
Collaborator

jmbuhr commented Aug 9, 2024

Is there a difference between quarto check outside of nvim and :tabedit term://quarto check from nvim?

@kamransoomro84
Copy link
Author

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.

@kamransoomro84
Copy link
Author

kamransoomro84 commented Aug 9, 2024

I can confirm that if I open a neovim terminal, activate the environment and run quarto preview, it works.

@jmbuhr
Copy link
Collaborator

jmbuhr commented Aug 9, 2024

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?

@kamransoomro84
Copy link
Author

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.

@jmbuhr
Copy link
Collaborator

jmbuhr commented Aug 9, 2024

For example, the proposed solution in the reddit post of using $SHLVL seems rather elegant.

@jmbuhr
Copy link
Collaborator

jmbuhr commented Aug 9, 2024

oh

@kamransoomro84
Copy link
Author

Also I'm using fish not bash.

@kamransoomro84
Copy link
Author

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.

@kamransoomro84
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants