garrettj403 / SciencePlots

Matplotlib styles for scientific plotting
MIT License
7.12k stars 709 forks source link

Using widgets is laggy with SciencePlots #112

Closed ShaiAvr closed 7 months ago

ShaiAvr commented 7 months ago

Environment

System: macOS-14.4.1-arm64-arm-64bit
Python: 3.11.7 (main, Dec  6 2023, 14:53:23) [Clang 15.0.0 (clang-1500.0.40.1)]
SciencePlots: 2.1.1
Matplotlib: 3.8.2
LaTeX distro:
pdfTeX 3.141592653-2.6-1.40.25 (TeX Live 2023)
kpathsea version 6.3.5
Copyright 2023 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.39; using libpng 1.6.39
Compiled with zlib 1.2.13; using zlib 1.2.13
Compiled with xpdf version 4.04

Affected styles

["science", "grid"]

Describe the issue here

I wanted to add interactive sliders to my plot, and I found that the mpl_interactions library is a nice and easy way to achieve this. I used a simple example from their site and modified it to suit my style. When running without SciencePlots (that is, without mpl.style.use(["science", "grid"])), everything is responsive and smooth: I can smoothly change the sliders and observe the changes in my plots. However, using SciencePlots causes the sliders to become laggy, and the plots also update with lags and are less responsive.

Why does SciencePlots causes mpl_interactions to be laggy and slow, and how can I fix this?

How can we replicate it? What have you tried? Please, add a reproducible example

import matplotlib as mpl
import matplotlib.pyplot as plt
import mpl_interactions.ipyplot as iplt
import numpy as np

import scienceplots  # noqa: F401

mpl.style.use(["science", "grid"])  # Comment this line to run smoothly
mpl.rcParams["font.size"] = 14

x = np.linspace(0, np.pi, 100)
tau = np.linspace(0.5, 10, 100)

def f1(x, tau, beta):
    return np.sin(x * tau) * x * beta

def f2(x, tau, beta):
    return np.sin(x * beta) * x * tau

fig, ax = plt.subplots(figsize=(8, 8))
controls = iplt.plot(x, f1, ax=ax, tau=tau, beta=(1, 10, 100), label="f1")
iplt.plot(x, f2, controls=controls, label="f2")
ax.legend()

fig.tight_layout()
plt.show()

Extra info

No response

ShaiAvr commented 7 months ago

After further investigation, I found that this issue occurs with SciencePlots in general and not only with mpl_interactions. I made this demo which only uses matplotlib's widgets and the problem still happens: smooth and responsive transitions without SciencePlots and it becomes laggy and slow with SciencePlots.

from matplotlib.widgets import Slider
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

import scienceplots  # noqa: F401

# mpl.style.use(["science"])  # Uncomment this line to see laggy UI with SciencePlots
mpl.rcParams["font.size"] = 14

def f(x, tau, beta):
    return np.sin(x * tau) * x**beta

x = np.linspace(0, 10, 1000)

fig, ax = plt.subplots(figsize=(8, 8))
(line,) = ax.plot(x, f(x, 1, 1))

fig_ui = plt.figure(figsize=(8, 1))
ax_tau = fig_ui.add_axes([0.1, 0.6, 0.8, 0.05])
s_tau = Slider(ax=ax_tau, label="tau", valmin=0.1, valmax=10, valinit=1)
ax_beta = fig_ui.add_axes([0.1, 0.1, 0.8, 0.05])
s_beta = Slider(ax=ax_beta, label="beta", valmin=0.1, valmax=10, valinit=1)

def update(val):
    line.set_ydata(f(x, s_tau.val, s_beta.val))
    fig.canvas.draw_idle()

s_tau.on_changed(update)
s_beta.on_changed(update)

fig.tight_layout()
plt.show()
echedey-ls commented 7 months ago

I suspect the issue relies not in SciencePlots, but in Matplotlib's backend: LaTeX. I would expect LaTeX rendering to be very much slower since that needs to be called as a different process for each one of the text figures (i.e. labels).

Can you benchmark with the "no-latex" style? You can append it to the styles list after "science", else the dont-use-latex config will be overridden.

WhiteSymmetry commented 7 months ago

You can install these to avoid latex problems:

python -m pip install -U mpl_interactions scienceplots pylatexenc pdflatex latexcodec latextools latex latexify-py jupyter-latex-envs ipympl

sudo apt install cm-super dvipng texlive-latex-extra texlive-fonts-recommended texlive-latex-recommended ghostscript

If you do it this way for interactive and faster backend use, you will be able to use latex smoothly and quickly.

Backends: 'GTK3Agg', 'GTK3Cairo', 'GTK4Agg', 'GTK4Cairo', 'MacOSX', 'nbAgg', 'QtAgg', 'QtCairo', 'Qt5Agg', 'Qt5Cairo', 'TkAgg', 'TkCairo', 'WebAgg', 'WX', 'WXAgg', 'WXCairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template'

displaying plots interactively: TkAgg, QtAgg, GTK4Agg, Gtk3Agg, WxAgg, and MacOSX.

import matplotlib import matplotlib as mpl import matplotlib.pyplot as plt matplotlib.use('TkAgg') # working, more speed than qtagg print(matplotlib.get_backend())

( matplotlib.use('qtagg') # working, PyQt6, PySide6, PyQt5, PySide2 for dynamic plots matplotlib.use('GTK3Agg') # working matplotlib.use('WebAgg') # working )

ShaiAvr commented 7 months ago

@echedey-ls Indeed, using LaTeX was the problem. If I run with the "no-latex" option, everything runs smoothly.

ShaiAvr commented 7 months ago

@WhiteSymmetry I will try it. About the second installation command: sudo apt install cm-super dvipng texlive-latex-extra texlive-fonts-recommended texlive-latex-recommended ghostscript, I have a MacBook and a Windows 11 desktop so, sudo apt install doesn't really work. I assume this command is meant to install TexLive. If so, then I already have it installed on both machines. If there is something else, can you please clarify what the second command tries to install and what to do on Mac and Windows?

ShaiAvr commented 7 months ago

@WhiteSymmetry In addition, the installation of the Python packages you mentioned failed. It claims that it's impossible to resolve the dependencies:

Collecting pylatexenc
  Downloading pylatexenc-2.10.tar.gz (162 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 162.6/162.6 kB 822.0 kB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting pdflatex
  Downloading pdflatex-0.1.3-py3-none-any.whl.metadata (3.4 kB)
Collecting latextools
  Downloading latextools-0.5.0-py3-none-any.whl.metadata (7.4 kB)
Collecting latex
  Downloading latex-0.7.0.tar.gz (6.5 kB)
  Preparing metadata (setup.py) ... done
Collecting latexify-py
  Downloading latexify_py-0.4.3.post1-py3-none-any.whl.metadata (4.2 kB)
Collecting jupyter_latex_envs
  Downloading jupyter_latex_envs-1.4.6.tar.gz (861 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 861.7/861.7 kB 4.8 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Requirement already satisfied: ipympl in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (0.9.3)
Collecting attrs<19.0,>=18.2 (from pdflatex)
  Downloading attrs-18.2.0-py2.py3-none-any.whl.metadata (11 kB)
Collecting fs (from latextools)
  Downloading fs-2.4.16-py2.py3-none-any.whl.metadata (6.3 kB)
Collecting tempdir (from latex)
  Downloading tempdir-0.7.1.tar.gz (5.9 kB)
  Preparing metadata (setup.py) ... done
Collecting data (from latex)
  Downloading data-0.4.tar.gz (7.0 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: future in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from latex) (0.18.3)
Collecting shutilwhich (from latex)
  Downloading shutilwhich-1.1.0.tar.gz (2.3 kB)
  Preparing metadata (setup.py) ... done
Collecting dill>=0.3.2 (from latexify-py)
  Downloading dill-0.3.8-py3-none-any.whl.metadata (10 kB)
Requirement already satisfied: ipython in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter_latex_envs) (8.20.0)
Requirement already satisfied: jupyter_core in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter_latex_envs) (5.7.1)
Requirement already satisfied: nbconvert in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter_latex_envs) (7.14.1)
Collecting notebook>=4.0 (from jupyter_latex_envs)
  Downloading notebook-7.1.2-py3-none-any.whl.metadata (10 kB)
Requirement already satisfied: traitlets>=4.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter_latex_envs) (5.14.1)
Requirement already satisfied: numpy in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipympl) (1.26.3)
Requirement already satisfied: ipython-genutils in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipympl) (0.2.0)
Requirement already satisfied: pillow in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipympl) (10.2.0)
Requirement already satisfied: ipywidgets<9,>=7.6.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipympl) (8.1.1)
Requirement already satisfied: matplotlib<4,>=3.4.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipympl) (3.8.2)
Requirement already satisfied: decorator in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (5.1.1)
Requirement already satisfied: jedi>=0.16 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (0.19.1)
Requirement already satisfied: matplotlib-inline in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (0.1.6)
Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (3.0.43)
Requirement already satisfied: pygments>=2.4.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (2.17.2)
Requirement already satisfied: stack-data in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (0.6.3)
Requirement already satisfied: pexpect>4.3 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (4.9.0)
Requirement already satisfied: comm>=0.1.3 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipywidgets<9,>=7.6.0->ipympl) (0.2.1)
Requirement already satisfied: widgetsnbextension~=4.0.9 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipywidgets<9,>=7.6.0->ipympl) (4.0.9)
Requirement already satisfied: jupyterlab-widgets~=3.0.9 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipywidgets<9,>=7.6.0->ipympl) (3.0.9)
Requirement already satisfied: contourpy>=1.0.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (1.2.0)
Requirement already satisfied: cycler>=0.10 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (4.47.2)
Requirement already satisfied: kiwisolver>=1.3.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (1.4.5)
Requirement already satisfied: packaging>=20.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (23.2)
Requirement already satisfied: pyparsing>=2.3.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (3.1.1)
Requirement already satisfied: python-dateutil>=2.7 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (2.8.2)
Requirement already satisfied: jupyter-server<3,>=2.4.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from notebook>=4.0->jupyter_latex_envs) (2.12.4)
Requirement already satisfied: jupyterlab-server<3,>=2.22.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from notebook>=4.0->jupyter_latex_envs) (2.25.2)
Collecting jupyterlab<4.2,>=4.1.1 (from notebook>=4.0->jupyter_latex_envs)
  Downloading jupyterlab-4.1.5-py3-none-any.whl.metadata (15 kB)
Requirement already satisfied: notebook-shim<0.3,>=0.2 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from notebook>=4.0->jupyter_latex_envs) (0.2.3)
Requirement already satisfied: tornado>=6.2.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from notebook>=4.0->jupyter_latex_envs) (6.4)
Requirement already satisfied: six in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from data->latex) (1.16.0)
Collecting funcsigs (from data->latex)
  Downloading funcsigs-1.0.2-py2.py3-none-any.whl.metadata (14 kB)
Collecting appdirs~=1.4.3 (from fs->latextools)
  Downloading appdirs-1.4.4-py2.py3-none-any.whl.metadata (9.0 kB)
Requirement already satisfied: setuptools in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from fs->latextools) (69.2.0)
Requirement already satisfied: platformdirs>=2.5 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter_core->jupyter_latex_envs) (4.1.0)
Requirement already satisfied: beautifulsoup4 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (4.12.2)
Requirement already satisfied: bleach!=5.0.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (6.1.0)
Requirement already satisfied: defusedxml in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (0.7.1)
Requirement already satisfied: jinja2>=3.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (3.1.3)
Requirement already satisfied: jupyterlab-pygments in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (0.3.0)
Requirement already satisfied: markupsafe>=2.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (2.1.3)
Requirement already satisfied: mistune<4,>=2.0.3 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (3.0.2)
Requirement already satisfied: nbclient>=0.5.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (0.9.0)
Requirement already satisfied: nbformat>=5.7 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (5.9.2)
Requirement already satisfied: pandocfilters>=1.4.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (1.5.0)
Requirement already satisfied: tinycss2 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (1.2.1)
Requirement already satisfied: webencodings in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from bleach!=5.0.0->nbconvert->jupyter_latex_envs) (0.5.1)
Requirement already satisfied: parso<0.9.0,>=0.8.3 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jedi>=0.16->ipython->jupyter_latex_envs) (0.8.3)
Requirement already satisfied: anyio>=3.1.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (4.2.0)
Requirement already satisfied: argon2-cffi in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (23.1.0)
Requirement already satisfied: jupyter-client>=7.4.4 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (8.6.0)
Requirement already satisfied: jupyter-events>=0.9.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.9.0)
Requirement already satisfied: jupyter-server-terminals in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.5.1)
Requirement already satisfied: overrides in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (7.4.0)
Requirement already satisfied: prometheus-client in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.19.0)
Requirement already satisfied: pyzmq>=24 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (25.1.2)
Requirement already satisfied: send2trash>=1.8.2 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (1.8.2)
Requirement already satisfied: terminado>=0.8.3 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.18.0)
Requirement already satisfied: websocket-client in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (1.7.0)
Requirement already satisfied: async-lru>=1.0.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs) (2.0.4)
Collecting httpx>=0.25.0 (from jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs)
  Downloading httpx-0.27.0-py3-none-any.whl.metadata (7.2 kB)
Requirement already satisfied: ipykernel in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs) (6.28.0)
Requirement already satisfied: jupyter-lsp>=2.0.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs) (2.2.1)
Requirement already satisfied: babel>=2.10 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs) (2.14.0)
Requirement already satisfied: json5>=0.9.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs) (0.9.14)
Requirement already satisfied: jsonschema>=4.18.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs) (4.20.0)
Requirement already satisfied: requests>=2.31 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs) (2.31.0)
Requirement already satisfied: fastjsonschema in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbformat>=5.7->nbconvert->jupyter_latex_envs) (2.19.1)
Requirement already satisfied: ptyprocess>=0.5 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from pexpect>4.3->ipython->jupyter_latex_envs) (0.7.0)
Requirement already satisfied: wcwidth in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython->jupyter_latex_envs) (0.2.13)
Requirement already satisfied: soupsieve>1.2 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from beautifulsoup4->nbconvert->jupyter_latex_envs) (2.5)
Requirement already satisfied: executing>=1.2.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from stack-data->ipython->jupyter_latex_envs) (2.0.1)
Requirement already satisfied: asttokens>=2.1.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from stack-data->ipython->jupyter_latex_envs) (2.4.1)
Requirement already satisfied: pure-eval in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from stack-data->ipython->jupyter_latex_envs) (0.2.2)
Requirement already satisfied: idna>=2.8 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from anyio>=3.1.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (3.6)
Requirement already satisfied: sniffio>=1.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from anyio>=3.1.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (1.3.0)
Requirement already satisfied: certifi in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from httpx>=0.25.0->jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs) (2023.11.17)
Collecting httpcore==1.* (from httpx>=0.25.0->jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs)
  Downloading httpcore-1.0.5-py3-none-any.whl.metadata (20 kB)
Requirement already satisfied: h11<0.15,>=0.13 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from httpcore==1.*->httpx>=0.25.0->jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs) (0.14.0)
INFO: pip is looking at multiple versions of jsonschema to determine which version is compatible with other requirements. This could take a while.
Collecting jsonschema>=4.18.0 (from jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs)
  Downloading jsonschema-4.21.1-py3-none-any.whl.metadata (7.8 kB)
  Downloading jsonschema-4.21.0-py3-none-any.whl.metadata (8.0 kB)
  Downloading jsonschema-4.19.2-py3-none-any.whl.metadata (7.9 kB)
  Downloading jsonschema-4.19.1-py3-none-any.whl.metadata (7.9 kB)
  Downloading jsonschema-4.19.0-py3-none-any.whl.metadata (8.2 kB)
  Downloading jsonschema-4.18.6-py3-none-any.whl.metadata (7.8 kB)
  Downloading jsonschema-4.18.5-py3-none-any.whl.metadata (7.7 kB)
INFO: pip is still looking at multiple versions of jsonschema to determine which version is compatible with other requirements. This could take a while.
  Downloading jsonschema-4.18.4-py3-none-any.whl.metadata (7.8 kB)
  Downloading jsonschema-4.18.3-py3-none-any.whl.metadata (7.9 kB)
  Downloading jsonschema-4.18.2-py3-none-any.whl.metadata (7.8 kB)
  Downloading jsonschema-4.18.1-py3-none-any.whl.metadata (7.8 kB)
  Downloading jsonschema-4.18.0-py3-none-any.whl.metadata (10 kB)
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. See https://pip.pypa.io/warnings/backtracking for guidance. If you want to abort this run, press Ctrl + C.
Collecting nbformat>=5.7 (from nbconvert->jupyter_latex_envs)
  Downloading nbformat-5.10.4-py3-none-any.whl.metadata (3.6 kB)
Collecting jupyterlab-server<3,>=2.22.1 (from notebook>=4.0->jupyter_latex_envs)
  Downloading jupyterlab_server-2.25.4-py3-none-any.whl.metadata (5.9 kB)
  Downloading jupyterlab_server-2.25.3-py3-none-any.whl.metadata (5.9 kB)
  Using cached jupyterlab_server-2.25.2-py3-none-any.whl.metadata (5.9 kB)
  Downloading jupyterlab_server-2.25.1-py3-none-any.whl.metadata (5.9 kB)
  Downloading jupyterlab_server-2.25.0-py3-none-any.whl.metadata (5.9 kB)
  Downloading jupyterlab_server-2.24.0-py3-none-any.whl.metadata (5.8 kB)
Collecting jsonschema>=4.17.3 (from jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs)
  Downloading jsonschema-4.17.3-py3-none-any.whl.metadata (7.9 kB)
Collecting pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 (from jsonschema>=4.17.3->jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs)
  Downloading pyrsistent-0.20.0-cp311-cp311-macosx_10_9_universal2.whl.metadata (27 kB)
Requirement already satisfied: python-json-logger>=2.0.4 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (2.0.7)
Requirement already satisfied: pyyaml>=5.3 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (6.0.1)
Requirement already satisfied: referencing in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.32.1)
Requirement already satisfied: rfc3339-validator in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.1.4)
Requirement already satisfied: rfc3986-validator>=0.1.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.1.1)
Collecting jupyter-events>=0.9.0 (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs)
  Downloading jupyter_events-0.10.0-py3-none-any.whl.metadata (5.9 kB)
  Downloading jupyter_events-0.9.1-py3-none-any.whl.metadata (5.7 kB)
  Using cached jupyter_events-0.9.0-py3-none-any.whl.metadata (5.7 kB)
Collecting nbformat>=5.7 (from nbconvert->jupyter_latex_envs)
  Downloading nbformat-5.10.3-py3-none-any.whl.metadata (3.6 kB)
  Downloading nbformat-5.10.2-py3-none-any.whl.metadata (3.6 kB)
  Downloading nbformat-5.10.1-py3-none-any.whl.metadata (3.6 kB)
  Downloading nbformat-5.10.0-py3-none-any.whl.metadata (3.6 kB)
  Using cached nbformat-5.9.2-py3-none-any.whl.metadata (3.4 kB)
  Downloading nbformat-5.9.1-py3-none-any.whl.metadata (3.3 kB)
  Downloading nbformat-5.9.0-py3-none-any.whl.metadata (3.3 kB)
  Downloading nbformat-5.8.0-py3-none-any.whl.metadata (3.5 kB)
  Downloading nbformat-5.7.3-py3-none-any.whl.metadata (5.0 kB)
  Downloading nbformat-5.7.2-py3-none-any.whl.metadata (5.0 kB)
  Downloading nbformat-5.7.1-py3-none-any.whl.metadata (5.0 kB)
  Downloading nbformat-5.7.0-py3-none-any.whl.metadata (4.7 kB)
Collecting jupyterlab-server<3,>=2.22.1 (from notebook>=4.0->jupyter_latex_envs)
  Downloading jupyterlab_server-2.23.0-py3-none-any.whl.metadata (5.8 kB)
  Downloading jupyterlab_server-2.22.1-py3-none-any.whl.metadata (5.9 kB)
Collecting pdflatex
  Downloading pdflatex-0.1.2-py3-none-any.whl.metadata (3.4 kB)
  Downloading pdflatex-0.1.1-py3-none-any.whl.metadata (405 bytes)
  Downloading pdflatex-0.1.0-py3-none-any.whl.metadata (405 bytes)
ERROR: Cannot install jsonschema==4.20.0, jupyterlab-server and pdflatex==0.1.0 because these package versions have conflicting dependencies.

The conflict is caused by:
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.20.0 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.21.1 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.21.0 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.19.2 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.19.1 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.19.0 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.6 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.5 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.4 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.3 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.2 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.1 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.0 depends on attrs>=22.2.0

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

Another minor point is that latexcodec is probably unnecessary. It's Pypi page says to use pylatexenc which you already listed.

echedey-ls commented 7 months ago

If I run with the "no-latex" option, everything runs smoothly.

I'm glad to hear that! Feel free to close if solved.

@WhiteSymmetry maybe I wasn't clear enough and you misunderstood my use of the word backend. I was referring to the text rendering backend, not the GUI one.

The alternative to LaTeX text rendering is bundled into Matplotlib. For this reason, it is much faster than LaTeX calls and output extraction.

WhiteSymmetry commented 7 months ago

@WhiteSymmetry In addition, the installation of the Python packages you mentioned failed. It claims that it's impossible to resolve the dependencies:

Collecting pylatexenc
  Downloading pylatexenc-2.10.tar.gz (162 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 162.6/162.6 kB 822.0 kB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting pdflatex
  Downloading pdflatex-0.1.3-py3-none-any.whl.metadata (3.4 kB)
Collecting latextools
  Downloading latextools-0.5.0-py3-none-any.whl.metadata (7.4 kB)
Collecting latex
  Downloading latex-0.7.0.tar.gz (6.5 kB)
  Preparing metadata (setup.py) ... done
Collecting latexify-py
  Downloading latexify_py-0.4.3.post1-py3-none-any.whl.metadata (4.2 kB)
Collecting jupyter_latex_envs
  Downloading jupyter_latex_envs-1.4.6.tar.gz (861 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 861.7/861.7 kB 4.8 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Requirement already satisfied: ipympl in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (0.9.3)
Collecting attrs<19.0,>=18.2 (from pdflatex)
  Downloading attrs-18.2.0-py2.py3-none-any.whl.metadata (11 kB)
Collecting fs (from latextools)
  Downloading fs-2.4.16-py2.py3-none-any.whl.metadata (6.3 kB)
Collecting tempdir (from latex)
  Downloading tempdir-0.7.1.tar.gz (5.9 kB)
  Preparing metadata (setup.py) ... done
Collecting data (from latex)
  Downloading data-0.4.tar.gz (7.0 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: future in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from latex) (0.18.3)
Collecting shutilwhich (from latex)
  Downloading shutilwhich-1.1.0.tar.gz (2.3 kB)
  Preparing metadata (setup.py) ... done
Collecting dill>=0.3.2 (from latexify-py)
  Downloading dill-0.3.8-py3-none-any.whl.metadata (10 kB)
Requirement already satisfied: ipython in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter_latex_envs) (8.20.0)
Requirement already satisfied: jupyter_core in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter_latex_envs) (5.7.1)
Requirement already satisfied: nbconvert in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter_latex_envs) (7.14.1)
Collecting notebook>=4.0 (from jupyter_latex_envs)
  Downloading notebook-7.1.2-py3-none-any.whl.metadata (10 kB)
Requirement already satisfied: traitlets>=4.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter_latex_envs) (5.14.1)
Requirement already satisfied: numpy in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipympl) (1.26.3)
Requirement already satisfied: ipython-genutils in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipympl) (0.2.0)
Requirement already satisfied: pillow in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipympl) (10.2.0)
Requirement already satisfied: ipywidgets<9,>=7.6.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipympl) (8.1.1)
Requirement already satisfied: matplotlib<4,>=3.4.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipympl) (3.8.2)
Requirement already satisfied: decorator in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (5.1.1)
Requirement already satisfied: jedi>=0.16 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (0.19.1)
Requirement already satisfied: matplotlib-inline in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (0.1.6)
Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (3.0.43)
Requirement already satisfied: pygments>=2.4.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (2.17.2)
Requirement already satisfied: stack-data in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (0.6.3)
Requirement already satisfied: pexpect>4.3 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipython->jupyter_latex_envs) (4.9.0)
Requirement already satisfied: comm>=0.1.3 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipywidgets<9,>=7.6.0->ipympl) (0.2.1)
Requirement already satisfied: widgetsnbextension~=4.0.9 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipywidgets<9,>=7.6.0->ipympl) (4.0.9)
Requirement already satisfied: jupyterlab-widgets~=3.0.9 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from ipywidgets<9,>=7.6.0->ipympl) (3.0.9)
Requirement already satisfied: contourpy>=1.0.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (1.2.0)
Requirement already satisfied: cycler>=0.10 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (4.47.2)
Requirement already satisfied: kiwisolver>=1.3.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (1.4.5)
Requirement already satisfied: packaging>=20.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (23.2)
Requirement already satisfied: pyparsing>=2.3.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (3.1.1)
Requirement already satisfied: python-dateutil>=2.7 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from matplotlib<4,>=3.4.0->ipympl) (2.8.2)
Requirement already satisfied: jupyter-server<3,>=2.4.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from notebook>=4.0->jupyter_latex_envs) (2.12.4)
Requirement already satisfied: jupyterlab-server<3,>=2.22.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from notebook>=4.0->jupyter_latex_envs) (2.25.2)
Collecting jupyterlab<4.2,>=4.1.1 (from notebook>=4.0->jupyter_latex_envs)
  Downloading jupyterlab-4.1.5-py3-none-any.whl.metadata (15 kB)
Requirement already satisfied: notebook-shim<0.3,>=0.2 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from notebook>=4.0->jupyter_latex_envs) (0.2.3)
Requirement already satisfied: tornado>=6.2.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from notebook>=4.0->jupyter_latex_envs) (6.4)
Requirement already satisfied: six in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from data->latex) (1.16.0)
Collecting funcsigs (from data->latex)
  Downloading funcsigs-1.0.2-py2.py3-none-any.whl.metadata (14 kB)
Collecting appdirs~=1.4.3 (from fs->latextools)
  Downloading appdirs-1.4.4-py2.py3-none-any.whl.metadata (9.0 kB)
Requirement already satisfied: setuptools in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from fs->latextools) (69.2.0)
Requirement already satisfied: platformdirs>=2.5 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter_core->jupyter_latex_envs) (4.1.0)
Requirement already satisfied: beautifulsoup4 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (4.12.2)
Requirement already satisfied: bleach!=5.0.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (6.1.0)
Requirement already satisfied: defusedxml in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (0.7.1)
Requirement already satisfied: jinja2>=3.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (3.1.3)
Requirement already satisfied: jupyterlab-pygments in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (0.3.0)
Requirement already satisfied: markupsafe>=2.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (2.1.3)
Requirement already satisfied: mistune<4,>=2.0.3 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (3.0.2)
Requirement already satisfied: nbclient>=0.5.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (0.9.0)
Requirement already satisfied: nbformat>=5.7 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (5.9.2)
Requirement already satisfied: pandocfilters>=1.4.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (1.5.0)
Requirement already satisfied: tinycss2 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbconvert->jupyter_latex_envs) (1.2.1)
Requirement already satisfied: webencodings in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from bleach!=5.0.0->nbconvert->jupyter_latex_envs) (0.5.1)
Requirement already satisfied: parso<0.9.0,>=0.8.3 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jedi>=0.16->ipython->jupyter_latex_envs) (0.8.3)
Requirement already satisfied: anyio>=3.1.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (4.2.0)
Requirement already satisfied: argon2-cffi in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (23.1.0)
Requirement already satisfied: jupyter-client>=7.4.4 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (8.6.0)
Requirement already satisfied: jupyter-events>=0.9.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.9.0)
Requirement already satisfied: jupyter-server-terminals in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.5.1)
Requirement already satisfied: overrides in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (7.4.0)
Requirement already satisfied: prometheus-client in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.19.0)
Requirement already satisfied: pyzmq>=24 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (25.1.2)
Requirement already satisfied: send2trash>=1.8.2 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (1.8.2)
Requirement already satisfied: terminado>=0.8.3 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.18.0)
Requirement already satisfied: websocket-client in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (1.7.0)
Requirement already satisfied: async-lru>=1.0.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs) (2.0.4)
Collecting httpx>=0.25.0 (from jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs)
  Downloading httpx-0.27.0-py3-none-any.whl.metadata (7.2 kB)
Requirement already satisfied: ipykernel in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs) (6.28.0)
Requirement already satisfied: jupyter-lsp>=2.0.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs) (2.2.1)
Requirement already satisfied: babel>=2.10 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs) (2.14.0)
Requirement already satisfied: json5>=0.9.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs) (0.9.14)
Requirement already satisfied: jsonschema>=4.18.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs) (4.20.0)
Requirement already satisfied: requests>=2.31 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs) (2.31.0)
Requirement already satisfied: fastjsonschema in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from nbformat>=5.7->nbconvert->jupyter_latex_envs) (2.19.1)
Requirement already satisfied: ptyprocess>=0.5 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from pexpect>4.3->ipython->jupyter_latex_envs) (0.7.0)
Requirement already satisfied: wcwidth in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython->jupyter_latex_envs) (0.2.13)
Requirement already satisfied: soupsieve>1.2 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from beautifulsoup4->nbconvert->jupyter_latex_envs) (2.5)
Requirement already satisfied: executing>=1.2.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from stack-data->ipython->jupyter_latex_envs) (2.0.1)
Requirement already satisfied: asttokens>=2.1.0 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from stack-data->ipython->jupyter_latex_envs) (2.4.1)
Requirement already satisfied: pure-eval in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from stack-data->ipython->jupyter_latex_envs) (0.2.2)
Requirement already satisfied: idna>=2.8 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from anyio>=3.1.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (3.6)
Requirement already satisfied: sniffio>=1.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from anyio>=3.1.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (1.3.0)
Requirement already satisfied: certifi in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from httpx>=0.25.0->jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs) (2023.11.17)
Collecting httpcore==1.* (from httpx>=0.25.0->jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs)
  Downloading httpcore-1.0.5-py3-none-any.whl.metadata (20 kB)
Requirement already satisfied: h11<0.15,>=0.13 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from httpcore==1.*->httpx>=0.25.0->jupyterlab<4.2,>=4.1.1->notebook>=4.0->jupyter_latex_envs) (0.14.0)
INFO: pip is looking at multiple versions of jsonschema to determine which version is compatible with other requirements. This could take a while.
Collecting jsonschema>=4.18.0 (from jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs)
  Downloading jsonschema-4.21.1-py3-none-any.whl.metadata (7.8 kB)
  Downloading jsonschema-4.21.0-py3-none-any.whl.metadata (8.0 kB)
  Downloading jsonschema-4.19.2-py3-none-any.whl.metadata (7.9 kB)
  Downloading jsonschema-4.19.1-py3-none-any.whl.metadata (7.9 kB)
  Downloading jsonschema-4.19.0-py3-none-any.whl.metadata (8.2 kB)
  Downloading jsonschema-4.18.6-py3-none-any.whl.metadata (7.8 kB)
  Downloading jsonschema-4.18.5-py3-none-any.whl.metadata (7.7 kB)
INFO: pip is still looking at multiple versions of jsonschema to determine which version is compatible with other requirements. This could take a while.
  Downloading jsonschema-4.18.4-py3-none-any.whl.metadata (7.8 kB)
  Downloading jsonschema-4.18.3-py3-none-any.whl.metadata (7.9 kB)
  Downloading jsonschema-4.18.2-py3-none-any.whl.metadata (7.8 kB)
  Downloading jsonschema-4.18.1-py3-none-any.whl.metadata (7.8 kB)
  Downloading jsonschema-4.18.0-py3-none-any.whl.metadata (10 kB)
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. See https://pip.pypa.io/warnings/backtracking for guidance. If you want to abort this run, press Ctrl + C.
Collecting nbformat>=5.7 (from nbconvert->jupyter_latex_envs)
  Downloading nbformat-5.10.4-py3-none-any.whl.metadata (3.6 kB)
Collecting jupyterlab-server<3,>=2.22.1 (from notebook>=4.0->jupyter_latex_envs)
  Downloading jupyterlab_server-2.25.4-py3-none-any.whl.metadata (5.9 kB)
  Downloading jupyterlab_server-2.25.3-py3-none-any.whl.metadata (5.9 kB)
  Using cached jupyterlab_server-2.25.2-py3-none-any.whl.metadata (5.9 kB)
  Downloading jupyterlab_server-2.25.1-py3-none-any.whl.metadata (5.9 kB)
  Downloading jupyterlab_server-2.25.0-py3-none-any.whl.metadata (5.9 kB)
  Downloading jupyterlab_server-2.24.0-py3-none-any.whl.metadata (5.8 kB)
Collecting jsonschema>=4.17.3 (from jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs)
  Downloading jsonschema-4.17.3-py3-none-any.whl.metadata (7.9 kB)
Collecting pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 (from jsonschema>=4.17.3->jupyterlab-server<3,>=2.22.1->notebook>=4.0->jupyter_latex_envs)
  Downloading pyrsistent-0.20.0-cp311-cp311-macosx_10_9_universal2.whl.metadata (27 kB)
Requirement already satisfied: python-json-logger>=2.0.4 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (2.0.7)
Requirement already satisfied: pyyaml>=5.3 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (6.0.1)
Requirement already satisfied: referencing in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.32.1)
Requirement already satisfied: rfc3339-validator in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.1.4)
Requirement already satisfied: rfc3986-validator>=0.1.1 in /Users/shai/.pyenv/versions/3.11.7/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs) (0.1.1)
Collecting jupyter-events>=0.9.0 (from jupyter-server<3,>=2.4.0->notebook>=4.0->jupyter_latex_envs)
  Downloading jupyter_events-0.10.0-py3-none-any.whl.metadata (5.9 kB)
  Downloading jupyter_events-0.9.1-py3-none-any.whl.metadata (5.7 kB)
  Using cached jupyter_events-0.9.0-py3-none-any.whl.metadata (5.7 kB)
Collecting nbformat>=5.7 (from nbconvert->jupyter_latex_envs)
  Downloading nbformat-5.10.3-py3-none-any.whl.metadata (3.6 kB)
  Downloading nbformat-5.10.2-py3-none-any.whl.metadata (3.6 kB)
  Downloading nbformat-5.10.1-py3-none-any.whl.metadata (3.6 kB)
  Downloading nbformat-5.10.0-py3-none-any.whl.metadata (3.6 kB)
  Using cached nbformat-5.9.2-py3-none-any.whl.metadata (3.4 kB)
  Downloading nbformat-5.9.1-py3-none-any.whl.metadata (3.3 kB)
  Downloading nbformat-5.9.0-py3-none-any.whl.metadata (3.3 kB)
  Downloading nbformat-5.8.0-py3-none-any.whl.metadata (3.5 kB)
  Downloading nbformat-5.7.3-py3-none-any.whl.metadata (5.0 kB)
  Downloading nbformat-5.7.2-py3-none-any.whl.metadata (5.0 kB)
  Downloading nbformat-5.7.1-py3-none-any.whl.metadata (5.0 kB)
  Downloading nbformat-5.7.0-py3-none-any.whl.metadata (4.7 kB)
Collecting jupyterlab-server<3,>=2.22.1 (from notebook>=4.0->jupyter_latex_envs)
  Downloading jupyterlab_server-2.23.0-py3-none-any.whl.metadata (5.8 kB)
  Downloading jupyterlab_server-2.22.1-py3-none-any.whl.metadata (5.9 kB)
Collecting pdflatex
  Downloading pdflatex-0.1.2-py3-none-any.whl.metadata (3.4 kB)
  Downloading pdflatex-0.1.1-py3-none-any.whl.metadata (405 bytes)
  Downloading pdflatex-0.1.0-py3-none-any.whl.metadata (405 bytes)
ERROR: Cannot install jsonschema==4.20.0, jupyterlab-server and pdflatex==0.1.0 because these package versions have conflicting dependencies.

The conflict is caused by:
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.20.0 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.21.1 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.21.0 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.19.2 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.19.1 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.19.0 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.6 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.5 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.4 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.3 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.2 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.1 depends on attrs>=22.2.0
    pdflatex 0.1.0 depends on attrs<19.0 and >=18.2
    jsonschema 4.18.0 depends on attrs>=22.2.0

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

Another minor point is that latexcodec is probably unnecessary. It's Pypi page says to use pylatexenc which you already listed.

You can install packages one by one. You may not install the incompatible one. Not all of them are necessary in the list I wrote, but I wrote them as a list to be ready. For me, everything is installed in Python 3.11.8 without any problems.

"jsonschema==4.20.0, jupyterlab-server and pdflatex==0.1.0" may cause problems for this type of jsonschema because they all use different versions. After installing it separately, you can update the current version of jsonschema. If the old version remains, sometimes jupyterlab may not work.

WhiteSymmetry commented 7 months ago

If I run with the "no-latex" option, everything runs smoothly.

I'm glad to hear that! Feel free to close if solved.

@WhiteSymmetry maybe I wasn't clear enough and you misunderstood my use of the word backend. I was referring to the text rendering backend, not the GUI one.

The alternative to LaTeX text rendering is bundled into Matplotlib. For this reason, it is much faster than LaTeX calls and output extraction.

Thank you for your explanation. The situation you stated is both true and an important issue.

Matplotlib offers two main advantages when it comes to text rendering with LaTeX: flexibility and integration.

  1. Flexibility: Matplotlib's LaTeX support allows the use of various LaTeX packages (font packages, math packages, etc.), providing more flexibility. This can lead to impressive results, especially when you use the same fonts in your figures as in your main document.

  2. Integration: Matplotlib enables you to create visualizations directly within your Python code and save them in a wide range of formats (PNG, PDF, SVG, etc.). Direct work with LaTeX may not offer such straightforward integration.

However, there are some drawbacks to using LaTeX for text rendering:

  1. Speed: LaTeX rendering is slower than Matplotlib's built-in mathtext. Matplotlib caches rendered TeX expressions, so the first occurrence of an expression triggers a TeX compilation, while subsequent occurrences reuse the rendered image from the cache, making them faster.
  2. Setup and Dependencies: LaTeX support requires a working LaTeX installation. Additionally, Agg backends require dvipng, PS backend requires PSfrag, dvips, and Ghostscript.

Using LaTeX for text rendering within Matplotlib can be advantageous in certain situations, particularly when creating high-quality, professional-looking documents. However, if speed and simplicity are important, using Matplotlib's built-in mathtext might be more appropriate.

WhiteSymmetry commented 7 months ago

mpl.style.use(["science", "grid"]) --> plt.rcParams.update({"text.usetex": True,"font.family": "sans-serif","font.sans-serif": "Helvetica", "font.size": "16"})

If we write this code like this instead, we will use Matplotlib instead of Latex + Matplotlib, but this time we will be deprived of the additional capabilities of Latex (https://ctan.org/pkg/amsmath). Those who do not want to use latex can try it by making changes in the "style" section (https://github.com/garrettj403/SciencePlots/tree/master/scienceplots/styles) or generate new styles for themselves.

science.mplstyle: https://github.com/garrettj403/SciencePlots/blob/master/scienceplots/styles/science.mplstyle

.# Use serif fonts .# font.serif : Times font.family : serif mathtext.fontset : dejavuserif

.# Use LaTeX for math formatting text.usetex : True text.latex.preamble : \usepackage{amsmath} \usepackage{amssymb}

echedey-ls commented 7 months ago

Using LaTeX for text rendering within Matplotlib can be advantageous in certain situations, particularly when creating high-quality, professional-looking documents. However, if speed and simplicity are important, using Matplotlib's built-in mathtext might be more appropriate.

That's completely true @WhiteSymmetry

I've considered setting text.usetex to false by default and changing the no-latex style to latex. However, I don't have enough time to work on my TODO list (tests, documentation and this change). I should open issues for all that in the hope anybody can help. Feel free to open PRs if you want.

For this matter, I also have to speak with the author @garrettj403 for a few more permissions/configurations.

Closing this as completed since @ShaiAvr has solved their issue. Thanks @WhiteSymmetry for the examples.

mpl.style.use(["science", "grid"]) --> plt.rcParams.update({"text.usetex": True,"font.family": "sans-serif","font.sans-serif": "Helvetica", "font.size": "16"}) If we write this code like this instead, we will use Matplotlib instead of Latex + Matplotlib

(Minor correction here for everyone interested: for the we will use Matplotlib instead of Latex + Matplotlib statement to be true, you must set plt.rcParams.update({"text.usetex": False}) -instead of True- or use the SciencePlots style "no-latex" which sets this config option to false.

REMEMBER: order when specifying the styles is important - the last style in the plt.use([...]) list will override configuration options (i.e., rcParams) in the case multiple styles set them.