The Wayback Machine - https://web.archive.org/web/20240106173906/https://github.com/matplotlib/matplotlib/issues/27564
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

[Bug]: Matplotlib crashes Python on Windows after update #27564

Open
schtandard opened this issue Dec 23, 2023 · 3 comments
Open

[Bug]: Matplotlib crashes Python on Windows after update #27564

schtandard opened this issue Dec 23, 2023 · 3 comments
Labels
status: needs clarification Issues that need more information to resolve.

Comments

@schtandard
Copy link

schtandard commented Dec 23, 2023

Bug summary

After updating conda conda update --all calling plt.subplots() in Spyder crashes the IPython kernel. Outside of Spyder plt.show() this does not happen, but there plt.show() seems to crash Python.

How to reproduce

  • Install Miniconda on Windows.

  • Create a test environment: conda create -n testenv -c conda-forge spyder matplotlib && conda activate testenv

  • Create two test files.

    • mpltest1.py:

      from matplotlib import pyplot as plt
      plt.subplots()
    • mpltest2.py:

      from matplotlib import pyplot as plt
      plt.subplots()
      plt.show()
      print("Hello World!")
  • Open mpltest1 in Spyder and run it. (Runs fine.)

  • Run mpltest2 from the command line: python mpltest2.py (Runs fine.)

  • Update the test environment: conda update --all
    This should install blis and update intel-openmp and mkl:

    Package plan
    (testenv) C:\Users\wilde\Desktop\temp\spydertest>conda update --all
    Channels:
    - conda-forge
    - defaults
    Platform: win-64
    Collecting package metadata (repodata.json): done
    Solving environment: done
    
    ## Package Plan ##
    
      environment location: C:\Users\wilde\miniconda3\envs\testenv
    
    
    The following packages will be downloaded:
    
        package                    |            build
        ---------------------------|-----------------
        blis-0.9.0                 |       hcfcfb64_1         3.2 MB  conda-forge
        intel-openmp-2024.0.0      |   h57928b3_49840         2.2 MB  conda-forge
        libblas-3.9.0              |    20_win64_blis         1.5 MB  conda-forge
        libcblas-3.9.0             |    20_win64_blis         1.5 MB  conda-forge
        liblapack-3.9.0            |5_hd5c7e75_netlib         2.7 MB  conda-forge
        mkl-2024.0.0               |   h66d3029_49657       103.5 MB  conda-forge
        ------------------------------------------------------------
                                              Total:       114.7 MB
    
    The following NEW packages will be INSTALLED:
    
      blis               conda-forge/win-64::blis-0.9.0-hcfcfb64_1
    
    The following packages will be UPDATED:
    
      intel-openmp                      2023.2.0-h57928b3_50497 --> 2024.0.0-h57928b3_49840
      mkl                               2023.2.0-h6a75c08_50497 --> 2024.0.0-h66d3029_49657
    
    The following packages will be DOWNGRADED:
    
      libblas                                3.9.0-20_win64_mkl --> 3.9.0-20_win64_blis
      libcblas                               3.9.0-20_win64_mkl --> 3.9.0-20_win64_blis
      liblapack                              3.9.0-20_win64_mkl --> 3.9.0-5_hd5c7e75_netlib
    
  • Open mpltest1 in Spyder and run it.
    Fails with "access violation", the IPython kernel restarts.

    Error messages
    In[1]: runfile('C:/Users/wilde/Desktop/temp/spydertest/spydertest.py', wdir='C:/Users/wilde/Desktop/temp/spydertest')
    
    
    Windows fatal exception: access violation
    
    Windows fatal exception: access violation
    
    Windows fatal exception: access violationThread 0x00000c20
    
    Windows fatal exception: access violation
    
    (most recent call first):
    Windows fatal exception:   File access violation"
    
    C:\Users\wilde\miniconda3\envs\testenv\Lib\site-packages\ipykernel\parentpoller.pyWindows fatal exception: access violation"
    
    , line 93 in Windows fatal exception: access violationrun
    
    
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\threading.py", line 1073 in _bootstrap_inner
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\threading.py", line 1030 in _bootstrap
    
    
    Main thread:
    Thread 0x00004a70 (most recent call first):
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\site-packages\matplotlib\transforms.py", line 2436 in get_affine
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\site-packages\matplotlib\transforms.py", line 2437 in get_affine
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\site-packages\matplotlib\patches.py", line 587 in draw
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\site-packages\matplotlib\artist.py", line 72 in draw_wrapper
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\site-packages\matplotlib\figure.py", line 3153 in draw
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\site-packages\matplotlib\artist.py", line 72 in draw_wrapper
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\site-packages\matplotlib\artist.py", line 95 in draw_wrapper
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\site-packages\matplotlib\backends\backend_agg.py", line 388 in draw
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\site-packages\matplotlib\backend_bases.py", line 1893 in draw_idle
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\site-packages\matplotlib\_pylab_helpers.py", line 132 in draw_all
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\site-packages\matplotlib\pyplot.py", line 197 in _draw_all_if_interactive
      File "C:\Users\wilde\miniconda3\envs\testenv\Lib\site-packages\IPython\core\events.py", line 82 in trigger
    
    
    Restarting kernel...
    
  • Run mpltest2 from the command line: python mpltest2.py
    This also fails. A plot window briefly opens but then closes without showing any axes. "Hello World!" is never printed.

Additional information

I am not completely sure that this is something matplotlib can/should fix, it happens after updating other packages, after all. However, I don't know enough to locate the bug any further or to reproduce it without matplotlib and don't know where else to report it. Feel free to point me to the correct place if this is not it.

The error I am getting is similar to that discussed in #21511. However, that was due to a change in freetype which is not the case here.

Operating system

Windows

Matplotlib Version

3.8.2

Matplotlib Backend

QtAgg

Python version

Python 3.12.1

Jupyter version

No response

Installation

conda

@jklymak
Copy link
Member

jklymak commented Dec 23, 2023

Please isolate to installing Matplotlib and/or take up with spyder and ipympl. You've got too many possible things here that could be going wrong and the fact it only crashes in spyder doesn't make it sound like it is a Matplotlib issue.

@jklymak jklymak added the status: needs clarification Issues that need more information to resolve. label Dec 23, 2023
@schtandard
Copy link
Author

@jklymak But it doesn't only crash in Spyder; that's why I included mpltest2 for running in bare Python. Only there I don't get any error messages, just a crash. In Spyder at least some (hopefully useful) information is displayed.

To make sure, I repeated the procedure without Spyder (same steps as above for mpltest2):

  • conda create -n testenv2 -c conda-forge matplotlib && conda activate testenv2
  • python mpltest2.py (runs fine and prints Hello World!)
  • conda update --all (updates the same packages as above)
  • python mpltest2.py (crashes and does not print Hello World!, same as above)

@tacaswell
Copy link
Member

From the traceback it looks like

return Affine2D(np.dot(self._b.get_affine().get_matrix(),
self._a.get_affine().get_matrix()))

is the code that is failing. Given that this is a segfault and in a np.dot call my guess is that this is actually failing in the numpy c extensions. This is likely because you end up with incompatible versions of blas/lapack.

The thing that I find very confusing is that conda upgrade --all changes a freshly installed environment. Are you ending up crossing the defaults and cf channels? If anything, I think this should be a bug reported to anaconda as it is installing a set of incompatible packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs clarification Issues that need more information to resolve.
Projects
None yet
Development

No branches or pull requests

3 participants