简体   繁体   English

pycharm 随机发生错误:进程以退出代码 134 结束(被信号 6 中断:SIGABRT)

[英]pycharm error happening at random time: Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

I am working with pycharm community on a tensorflow model with keras backend, sometimes this error appears in a random time, specially after I call pyplot and close the window: I am working with pycharm community on a tensorflow model with keras backend, sometimes this error appears in a random time, specially after I call pyplot and close the window:

Exception ignored in: <bound method Image.__del__ of <tkinter.PhotoImage object at 0x7ff6406fad30>>
Traceback (most recent call last):
  File "/usr/lib/python3.6/tkinter/__init__.py", line 3507, in __del__
    self.tk.call('image', 'delete', self.name)
    RuntimeError: main thread is not in main loop

After this error, I need to close the python console and load my data again which is time-consuming (the data is a big dataset and the memory usage is considerable)出现此错误后,我需要关闭 python 控制台并再次加载我的数据,这很耗时(数据是一个大数据集,memory 使用量很大)

How do I resolve this problem?我该如何解决这个问题?

UPDATE: Here is the plot code:更新:这是 plot 代码:

import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot as plt
import numpy as np

data = np.ones((256,256))
fig = plt.figure()
ax = fig.add_subplot(111)
temp = np.transpose(data)
plt.title('title')
im = ax.imshow((temp), aspect='auto')
fig.colorbar(im)
plt.axes()

data2 = np.ones((256,256))
fig = plt.figure()
ax = fig.add_subplot(111)
temp = np.transpose(data2)
plt.title('title')
im = ax.imshow((temp), aspect='auto')
fig.colorbar(im)
plt.axes()

UPDATE 2:更新 2:

I have PyCharm 2021.2.3(Community Edition)我有PyCharm 2021.2.3(社区版)

build PC-212.5457.59
Runtime version: 11.0.12+7-b1504.40 amd64

I have the following packages installed:我安装了以下软件包:

Package                 Version            
----------------------- -------------------
absl-py                 0.9.0              
appdirs                 1.4.3              
apturl                  0.5.2              
asn1crypto              0.24.0             
astor                   0.8.1              
bleach                  2.1.2              
Brlapi                  0.6.6              
certifi                 2018.1.18          
chardet                 3.0.4              
command-not-found       0.3                
control                 0.9.0              
cryptography            2.1.4              
cupshelpers             1.0                
cycler                  0.10.0             
decorator               4.4.2              
defer                   1.0.6              
distlib                 0.3.0              
distro-info             0.18ubuntu0.18.04.1
entrypoints             0.2.3.post1        
filelock                3.0.12             
gast                    0.2.2              
google-pasta            0.1.8              
graphviz                0.14               
grpcio                  1.27.2             
h5py                    2.10.0             
html5lib                0.999999999        
httplib2                0.9.2              
idna                    2.6                
imageio                 2.9.0              
imageio-ffmpeg          0.4.3              
imgviz                  1.2.5              
importlib-metadata      1.5.0              
importlib-resources     1.3.1              
ipykernel               4.8.2              
ipython                 5.5.0              
ipython-genutils        0.2.0              
ipywidgets              6.0.0              
Jinja2                  2.10               
joblib                  0.14.1             
jsonschema              2.6.0              
jupyter-client          5.2.2              
jupyter-core            4.4.0              
Keras                   2.4.3              
Keras-Applications      1.0.8              
Keras-Preprocessing     1.1.0              
keyring                 10.6.0             
keyrings.alt            3.0                
kiwisolver              1.1.0              
labelme                 4.5.7              
language-selector       0.1                
launchpadlib            1.10.6             
lazr.restfulclient      0.13.5             
lazr.uri                1.0.3              
llvmlite                0.34.0             
louis                   3.5.0              
macaroonbakery          1.1.3              
Markdown                3.2.1              
MarkupSafe              1.0                
matplotlib              3.0.3              
mistune                 0.8.3              
moviepy                 1.0.3              
nbconvert               5.3.1              
nbformat                4.4.0              
netifaces               0.10.4             
networkx                2.5.1              
notebook                5.2.2              
numba                   0.51.2             
numpy                   1.19.5             
oauth                   1.0.1              
olefile                 0.45.1             
opt-einsum              3.2.0              
pandas                  1.0.4              
pandocfilters           1.4.2              
pexpect                 4.2.1              
pickleshare             0.7.4              
Pillow                  5.1.0              
pip                     20.0.2             
proglog                 0.1.9              
prompt-toolkit          1.0.15             
protobuf                3.11.3             
pycairo                 1.16.2             
pycrypto                2.6.1              
pycups                  1.9.73             
pydot                   1.4.1              
pydot-ng                2.0.0              
pydotplus               2.0.2              
Pygments                2.2.0              
pygobject               3.26.1             
pymacaroons             0.13.0             
PyNaCl                  1.1.2              
pyparsing               2.4.6              
pyRFC3339               1.0                
python-apt              1.6.5+ubuntu0.5    
python-dateutil         2.6.1              
python-debian           0.1.32             
pytz                    2018.3             
PyWavelets              1.1.1              
pyxdg                   0.25               
PyYAML                  3.12               
pyzmq                   16.0.2             
QtPy                    1.9.0              
reportlab               3.4.0              
requests                2.18.4             
requests-unixsocket     0.1.5              
scikit-image            0.17.2             
scikit-learn            0.22.2.post1       
scipy                   1.4.1              
screen-resolution-extra 0.0.0              
seaborn                 0.11.0             
SecretStorage           2.3.1              
setuptools              46.0.0             
simplegeneric           0.8.1              
simplejson              3.13.2             
six                     1.14.0             
sklearn                 0.0                
system-service          0.3                
systemd-python          234                
tensorboard             1.14.0             
tensorflow-estimator    1.14.0             
tensorflow-gpu          1.14.0             
termcolor               1.1.0              
terminado               0.7                
testpath                0.3.1              
tifffile                2020.9.3           
tornado                 4.5.3              
tqdm                    4.56.2             
traitlets               4.3.2              
ubuntu-drivers-common   0.0.0              
ufw                     0.36               
unattended-upgrades     0.1                
urllib3                 1.22               
virtualenv              20.0.10            
wadllib                 1.3.2              
wcwidth                 0.1.7              
webencodings            0.5                
Werkzeug                1.0.0              
wheel                   0.34.2             
wrapt                   1.12.1             
xkit                    0.0.0              
zipp                    3.1.0              
zope.interface          4.3.2  

Looks like this is part of an actively tracked issue with Tkinter in PyCharm.看起来这是 PyCharm 中 Tkinter 的积极跟踪问题的一部分。 You can find the reference on the Pycharm's developer's issue tracker .您可以在Pycharm 的开发者问题跟踪器上找到参考。 The issue is undiagnosed, but if looking at similar problems with Tk on StackOverflow , one can see that it's an issue with thread safety and/or multithreading.该问题尚未得到诊断,但如果在 StackOverflow 上查看 Tk 的类似问题,可以看出这是线程安全和/或多线程的问题。

All I can do is speculate as to the cause, which is not helpful, however, I can at least collate the suggested workarounds:我所能做的就是推测原因,这没有帮助,但是,我至少可以整理建议的解决方法:

  1. Switch to a different Matplotlib backend (See docs: What is a backend ?).切换到不同的 Matplotlib 后端(请参阅文档: 什么是后端?)。 Such as Qt5, but you will need to make sure they are available in your environment.例如 Qt5,但您需要确保它们在您的环境中可用。

    This approach is the most promising as other backends are better able to deal with not being the main thread or are explicitly safe for multi-threading.这种方法是最有前途的,因为其他后端能够更好地处理不是主线程或对多线程明确安全的问题。 It's also the simplest unless you have a really specific reason for preferring TkAgg.这也是最简单的,除非您有一个非常具体的理由偏爱 TkAgg。

  2. Do not use the debugger with interactive plots.不要将调试器与交互式绘图一起使用。

  3. Set "Variables Loading Policy" to "Synchronously" in Debugger as suggested by a PyCharm dev in the linked issue.按照链接问题中 PyCharm 开发人员的建议,在调试器中将“变量加载策略”设置为“同步”。

  4. Enable "Scientific mode" in Pycharm.在 Pycharm 中启用“科学模式”。

  5. More esoteric workarounds such as closing your figures within the code before drawing the second one.更深奥的解决方法,例如在绘制第二个之前在代码中关闭您的数字。 Example, after plotting the first figure:例如,在绘制第一个图之后:

     # Save out figure if desired, then close # Assuming not using a blocking draw/show call. fig.savefig('myfig.png') plt.close() # Object oriented: fig.close()

As per speculation to the cause, maybe PyCharm's debugger is kicking Tk off the main thread or runs it in a worker thread that is closed while the figure is still active or rendered.根据对原因的推测,也许 PyCharm 的调试器正在将 Tk 踢出主线程,或者在图形仍处于活动或呈现状态时关闭的工作线程中运行它。

Finally, please also take a look at the relevant documentation for Matplotlib , as your code example does not follow their recommended usage patterns.最后,还请查看Matplotlib 的相关文档,因为您的代码示例不遵循他们推荐的使用模式。 Specifically, learn about the differences between object oriented and the pyplot approach from the link.具体来说,从链接了解面向 object 和 pyplot 方法之间的区别。 Possibly, somewhat unlikely, if the code stuck to recommended ways of using Matplotlib as highlighted in their tutorial documents, the error might not appear.可能,有点不太可能,如果代码坚持使用 Matplotlib 的推荐方法,如其教程文档中突出显示的那样,错误可能不会出现。 This is just speculation.这只是猜测。

I would at least recommend not misusing plt.axes() as a roundabout way of forcing a render of your figure.我至少建议不要滥用 plt.axes() 作为强制渲染图形的迂回方式。 You already create an axes using the object oriented approach fig.add_subplot , so you do not need to create an empty axes with pyplot.您已经使用面向 object 的方法fig.add_subplot创建了一个轴,因此您不需要使用 pyplot 创建一个空轴。 Recall that figures can be memory heavy, so, if you are memory starved already from loading your dataset, you may find better performance and avoid using the swap by properly dealing with your figures such as closing them when done, not rendering them interactively unless needed, etc.回想一下,数字可能很重 memory,因此,如果您已经因加载数据集而饿死 memory,您可能会发现更好的性能并通过正确处理数字来避免使用交换,例如在完成时关闭它们,除非需要,否则不要以交互方式呈现它们, ETC。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Pycharm - 进程已完成,退出代码为 134(被信号 6:SIGABRT 中断)错误 - Pycharm - Process finished with exit code 134 (interrupted by signal 6: SIGABRT) error 进程以退出代码 134 结束(被信号 6 中断:SIGABRT) - Process finished with exit code 134 (interrupted by signal 6: SIGABRT) 进程以 Python OpenCV 中的退出代码 134(被信号 6:SIGABRT 中断)结束 - Process finished with exit code 134 (interrupted by signal 6: SIGABRT) in python OpenCV Python - 进程以退出代码 134 完成(被信号 6:SIGABRT 中断) - 海龟模块 - Python - Process finished with exit code 134 (interrupted by signal 6: SIGABRT) - turtle module Python 服务在调试模式下在 PyCharm 中崩溃并出现错误:进程已完成,退出代码为 138(被信号 10 中断:SIGBUS) - The Python service is crashing in PyCharm in debug mode with an error : Process finished with exit code 138 (interrupted by signal 10: SIGBUS) Pycharm - 运行 Open CV 代码直接进入“进程完成,退出代码 139(被信号 11 中断:SIGSEGV)” - Pycharm - Running Open CV Code goes straight to “Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)” 在 Pycharm 中导入 numpy 或 pandas 时,“进程以退出代码 132 完成(被信号 4 中断:SIGILL)” - "Process finished with exit code 132 (interrupted by signal 4: SIGILL)" when importing numpy or pandas in Pycharm 3D CNN 在 pycharm 上使用 keras-tensorflow(进程以退出代码 137 结束(被信号 9:SIGKILL 中断)) - 3D CNN using keras-tensorflow on pycharm ( Process finished with exit code 137 (interrupted by signal 9: SIGKILL) ) PyCharm 绘图问题“进程以退出代码 139 完成(被信号 11 中断:SIGSEGV)” - PyCharm Plotting Issue "Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)" 使用StringSubsequenceKernel的退出代码139(信号11:SIGSEGV中断)完成的过程 - Process finished with exit code 139 (interrupted by signal 11: SIGSEGV) with StringSubsequenceKernel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM