Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cannot save SVG file with FIPS compliant Python #18192

Closed
Milestone
@daytonb

Description

@daytonb

Bug report

Bug summary

If you use a FIPS (Federal Information Processing Standards) compliant Python install, then you cannot useplt.savefig to save an image in SVG format. This is because theRenderSVG._make_id method takes the first 10 characters of ahashlib.md5 digest of entries in the SVG as the ID for that part of the SVG file. The MD5 algorithm is disabled on FIPS compliant systems or in FIPS compliant Python installs.

Code for reproduction

The big requirement here is a FIPS compliant system or at least a Python install compiled to be FIPS compliant. Then the following code will reproduce the error.

To reproduce,

  1. I started a CentOS 8 virtual machine
  2. Ransudo fips-mode-setup --enable && sudo reboot
  3. After the reboot I confirmed FIPS mode had been enabled by runningfips-mode-setup --check and it returnedFIPS mode is enabled..
  4. sudo dnf install python3
  5. python3 -m venv venv
  6. ./venv/bin/python -m pip install -U pip setuptools
  7. ./venv/bin/python -m pip install matplotlib
  8. ./venv/bin/python demo.py. The contents ofdemo.py are listed below.
""" demo.py: demonstrates that matplotlib can't save SVGs if FIPS mode enabled """importmatplotlib.pyplotaspltplt.plot(range(10))plt.savefig(range10.png")plt.savefig("range10.svg")

Actual outcome

Traceback (most recent call last):  File "demo.py", line 5, in <module>    plt.savefig("range10.svg")  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/pyplot.py", line 842, in savefig    res = fig.savefig(*args, **kwargs)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/figure.py", line 2311, in savefig    self.canvas.print_figure(fname, **kwargs)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/backend_bases.py", line 2217, in print_figure    **kwargs)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/backends/backend_svg.py", line 1318, in print_svg    self._print_svg(filename, fh, **kwargs)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/backend_bases.py", line 1639, in wrapper    return func(*args, **kwargs)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/backends/backend_svg.py", line 1342, in _print_svg    self.figure.draw(renderer)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/artist.py", line 41, in draw_wrapper    return draw(artist, renderer, *args, **kwargs)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/figure.py", line 1864, in draw    renderer, self, artists, self.suppressComposite)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images    a.draw(renderer)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/artist.py", line 41, in draw_wrapper    return draw(artist, renderer, *args, **kwargs)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/cbook/deprecation.py", line 411, in wrapper    return func(*inner_args, **inner_kwargs)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/axes/_base.py", line 2748, in draw    mimage._draw_list_compositing_images(renderer, self, artists)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images    a.draw(renderer)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/artist.py", line 41, in draw_wrapper    return draw(artist, renderer, *args, **kwargs)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/axis.py", line 1169, in draw    tick.draw(renderer)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/artist.py", line 41, in draw_wrapper    return draw(artist, renderer, *args, **kwargs)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/axis.py", line 291, in draw    artist.draw(renderer)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/artist.py", line 41, in draw_wrapper    return draw(artist, renderer, *args, **kwargs)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/lines.py", line 854, in draw    fc_rgba)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/backends/backend_svg.py", line 683, in draw_markers    oid = self._make_id('m', dictkey)  File "/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/backends/backend_svg.py", line 440, in _make_id    m = hashlib.md5()ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS

Expected outcome

Expect no errors and an SVG named "range10.svg" that shows the same plot as a PNG named "range10.png".

Matplotlib version

  • Operating system: CentOS Linux release 8.2.2004 (Core)
    • fips-mode-setup --check returnsFIPS mode is enabled
  • Matplotlib version: 3.3.0
  • Matplotlib backend (print(matplotlib.get_backend())): agg
  • Python version: 3.6.8
  • Jupyter version (if applicable): NA
  • Other libraries:
[daytonb@centos-s-1vcpu-1gb-nyc1-01 ~]$ venv/bin/python -m pip listPackage         Version--------------- -------cycler          0.10.0kiwisolver      1.2.0matplotlib      3.3.0numpy           1.19.1Pillow          7.2.0pip             20.2.1pyparsing       2.4.7python-dateutil 2.8.1setuptools      49.2.1six             1.15.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp