RuntimeError: main thread is not in main loop

Console shuts down after I 'import importlib' and here is the error it gives.


>>> import importlib
Exception ignored in: <bound method Image.__del__ of <tkinter.PhotoImage object at 0x000001AF640E1D68>>
Traceback (most recent call last):
File "C:\Python36\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 0x000001AF63DBD5F8>>
Traceback (most recent call last):
File "C:\Python36\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 Variable.__del__ of <tkinter.IntVar object at 0x000001AF6410B0F0>>
Traceback (most recent call last):
File "C:\Python36\lib\tkinter\__init__.py", line 329, in __del__
if self._tk.getboolean(self._tk.call("info", "exists", self._name)):
RuntimeError: main thread is not in main loop
Exception ignored in: <bound method Image.__del__ of <tkinter.PhotoImage object at 0x000001AF6410B5F8>>
Traceback (most recent call last):
File "C:\Python36\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 Variable.__del__ of <tkinter.IntVar object at 0x000001AF6367F470>>
Traceback (most recent call last):
File "C:\Python36\lib\tkinter\__init__.py", line 329, in __del__
if self._tk.getboolean(self._tk.call("info", "exists", self._name)):
RuntimeError: main thread is not in main loop
Exception ignored in: <bound method Image.__del__ of <tkinter.PhotoImage object at 0x000001AF6367F278>>
Traceback (most recent call last):
File "C:\Python36\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 0x000001AF63AEA7F0>>
Traceback (most recent call last):
File "C:\Python36\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 0x000001AF643492B0>>
Traceback (most recent call last):
File "C:\Python36\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 0x000001AF640E1F60>>
Traceback (most recent call last):
File "C:\Python36\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 0x000001AF629B3C50>>
Traceback (most recent call last):
File "C:\Python36\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


0

Hello, 

 

Please try another interpreter, change it in https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html, and reopen the console. Seem like interpreter-specific, as it is not reproducible for me with Python 3.8.

0

Hi Tonya,

I installed python 3.8 but the error persists. I am using PyCharm 2021.1. Could it be because I installed python in an internet drive of my institution?

Exception ignored in: <function Image.__del__ at 0x0000021F653D18B0>
Traceback (most recent call last):
File "Y:\WORK\code\Python38\lib\tkinter\__init__.py", line 4017, in __del__
self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Exception ignored in: <function Variable.__del__ at 0x0000021F65350F70>
Traceback (most recent call last):
File "Y:\WORK\code\Python38\lib\tkinter\__init__.py", line 363, in __del__
if self._tk.getboolean(self._tk.call("info", "exists", self._name)):
RuntimeError: main thread is not in main loop
Exception ignored in: <function Image.__del__ at 0x0000021F653D18B0>
Traceback (most recent call last):
File "Y:\WORK\code\Python38\lib\tkinter\__init__.py", line 4017, in __del__
self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Exception ignored in: <function Image.__del__ at 0x0000021F653D18B0>
Traceback (most recent call last):
File "Y:\WORK\code\Python38\lib\tkinter\__init__.py", line 4017, in __del__
self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Exception ignored in: <function Image.__del__ at 0x0000021F653D18B0>
Traceback (most recent call last):
0

>Could it be because I installed python in an internet drive of my institution?

 

Yes, it might be the cause.  Please try installing Python locally and let me know how it goes. 

0

I moved Python3.8 to my local drive (C) and the error happened again.

0

Hello, 

 

Do you mean you have copied the folder where Python is installed to drive C? Or performed a new installation but to a different location? 

0

请先登录再写评论。