0

I want to compile a python file to a standalone .exe programm using pyinstaller onefile. Running the python file, everything works fine, but running the .exe file, it throws the exception

ModuleNotFoundError: No module named 'matplotlib.backends.backend_svg'

I am using schemdraw, and schemdraw uses matplotlib.

Because I dont want matplotlib to open a window everytime I export an svg I use the backend "Agg" with matplotlib.

import matplotlib.backends.backend_tkagg
import matplotlib
matplotlib.use('Agg')

  • I of course have tried reinstalling matplotlib
  • Using instead of pyinstaller --onefile <file> pyinstaller <file>
  • I tried putting import matplotlib.backends.backend_tkagg over import matplotlip
  • upgrading matplotlib pip install matplotlib --upgrade --user basicly this post. But since this isn't exactly my problem and none of it worked I am asking here

Thanks in advance

Hellow2
  • 33
  • 8

1 Answers1

0

Do you need to use Matplotlib for anything other than schemdraw? If not, you can set schemdraw to draw straight to SVG:

schemdraw.use('svg')

then it won't even go through Matplotlib.

Collin
  • 146
  • 4
  • No I don't have to use Matplotlib. But can you please either link a documentation or elaborate on the use? on `schemdraw.use('svg')` I can't find the documentation. Thanks – Hellow2 Jan 17 '22 at 11:24
  • [Documentation](https://schemdraw.readthedocs.io/en/stable/usage/backends.html#svg-backend). Works the same as the default Matplotlib backend; use either Drawing.save() or Drawing.get_imagedata() to get the svg as bytes. – Collin Jan 18 '22 at 04:48