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

Calling savefig() multiple times causes crash of Spyder IDE / IPython Kernel dying. #12409

Closed
RichardPflaum opened this issue Oct 5, 2018 · 3 comments

Comments

@RichardPflaum
Copy link

Bug report

Bug summary

Calling savefig() multiple times causes crash of Spyder IDE / IPython Kernel dying. The first time, the image is usually saved and sometimes even a couple more times, but eventually it causes a crash.
Yesterday everything still worked fine, today after a Windows update savefig started making these problems. The issue is independent of the target directory.

Code for reproduction

import matplotlib.pyplot as plt

for i in [1,2,3,4]:
    x=[1,2,3]
    y=[3,4,5]

    plt.figure()
    plt.plot(x,y,'r-')
    plt.savefig('test{0:0d}.png'.format(i))

Actual outcome

Spyder crashes or the IPython Kernel dies. Some figures are saved until it suddenly crashes.

Expected outcome

Saving figures.

Matplotlib version

  • Operating system: Windows 10 Pro v. 1809 installed on october 5th, 2018, build 17763.1
  • Matplotlib version: 3.0.0 (installed using conda)
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.6.6
  • Spyder version: 3.3.1
  • IPython version: 7.0.1
  • Other libraries: -
@jklymak
Copy link
Member

jklymak commented Oct 5, 2018

If you need spyder and/or ipython to trigger this bug I’d suggest the bug is elsewhere. If you can trigger from bare python please comment here and we can reopen. My guess is something is wrong w your install.

@jklymak jklymak closed this as completed Oct 5, 2018
@RichardPflaum
Copy link
Author

Hi again, I just ran into similar problems when executing the script via the windows command prompt. I used
>C:\ProgramData\Anaconda3\python.exe "C:\Users\RHu\Documents\test_savefig.py"
That should qualify as triggering from bare python, right? I also adjusted the script according to this post I found, so now it reads as:

import matplotlib.pyplot as plt

plt.ioff()
fig = plt.figure()
for i in range(20):
    x=[1,2,3]
    y=[3,4,5]
    ax = fig.add_subplot(111)
    ax.plot(x,y)
    plt.savefig("C:\\Users\\RHu\\Desktop\\plotfolder\\" + 'test{0:0d}.png'.format(i))
    plt.clf()
    print(i) # for debugging
plt.close() 

In this configuration, I realized the script only runs properly if the *.png files are not already present in the target directory. So, if the script is run with an empty target folder, the plots are saved just fine. If you then run the script again, it just prints 0 and 1 and then stops. I also saw something else: The problem only ever occurs for the *.png file format. With the *.jpg and *.pdf extensions, everything works as it should, also in Spyder. I think this might be a problem with the new Windows feature update from friday. Our IT told me the update was actually called back, so hopefully the next Windows update will fix it without you having to do anything. I'll just be using *.jpg format until then.

@anntzer anntzer reopened this Oct 8, 2018
@RichardPflaum
Copy link
Author

Hey again, so the bug was solely created by the bad Windows 10 v. 1809 Update. It was actually supposed to have been called back for the Windows Professional version, but due to an internal error by Microsoft it was released anyways. So you can consider this issue resolved. We just reset the Windows version to the previous state and now everything works fine again. Thank you for your efforts anyways!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants