Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am new to Python. I have written Web service using Django to save image in server. I am trying to save plot as image using below code and it works fine for 3 times, after that Python throws error. How to fix this issue ?

Exception ignored in: <bound method Image.__del__ of <tkinter.PhotoImage object at 0x000000000FE40048>>
Traceback (most recent call last):
  File "c:\dev\lib\tkinter\__init__.py", line 3504, in __del__
    self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Exception ignored in: <bound method Image.__del__ of <tkinter.PhotoImage object at 0x0000000010996438>>
Traceback (most recent call last):
  File "c:\dev\lib\tkinter\__init__.py", line 3504, in __del__
    self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Exception ignored in: <bound method Image.__del__ of <tkinter.PhotoImage object at 0x0000000010B8BF98>>
Traceback (most recent call last):
  File "c:\dev\lib\tkinter\__init__.py", line 3504, in __del__
    self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Tcl_AsyncDelete: async handler deleted by the wrong thread
**PYTHON CODE**  
fileName = id_generator()+".png"
filePath = settings.MEDIA_ROOT+"/"+fileName
fig.savefig(filePath, dpi=fig.dpi)
plt.close(fig) 
Response(fileName, status=status.HTTP_201_CREATED)
Package             Version
------------------- ---------
cassandra-driver    3.14.0
certifi             2018.4.16
cycler              0.10.0
Django              2.0.5
djangorestframework 3.8.2
kiwisolver          1.0.1
matplotlib          2.2.2
numpy               1.14.4
pandas              0.23.0
pip                 10.0.1
pyparsing           2.2.0
python-dateutil     2.7.3
pytz                2018.4
scikit-learn        0.19.1
scipy               1.1.0
setuptools          39.2.0
six                 1.11.0
wheel               0.31.1
wincertstore        0.2
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.