It looks like you're encountering an issue related to exporting Jupyter notebooks to PDF using nbconvert on your Mac M1. The error mentions a missing installation of xelatex (part of TeX), but you’ve already installed MacTeX and added it to the PATH. Here are a few steps you can take to troubleshoot further:
which xelatex
This should return the path to xelatex. If it doesn't, TeX may not be properly installed, even if MacTeX is on the path.
echo $PATH
The path /Library/TeX/texbin should appear in the output. If it doesn't, add the export command to your shell's profile file (~/.zshrc or ~/.bash_profile, depending on your shell).
pip install nbconvert[all]
This ensures all optional dependencies, including LaTeX, are included.
Restarting VS Code.
Checking for updates to the Jupyter extension.
Ensuring that the Python environment selected in VS Code is the same one where nbconvert and TeX are installed.
jupyter nbconvert --to pdf your_notebook.ipynb
This might provide more detailed error messages that can guide further troubleshooting.
jupyter nbconvert --to html your_notebook.ipynb