简体   繁体   English

X 服务器“localhost:10.0”上的 matplot lib“致命 IO 错误 25(设备的 ioctl 不合适)”

[英]matplot lib "fatal IO error 25 (Inappropriate ioctl for device) on X server "localhost:10.0"

I run a device monitoring script as a background process which is supposed to run forever.我将设备监控脚本作为应该永远运行的后台进程运行。 However the process got killed after 24+ hours with the error.但是,该过程在 24 小时以上后因错误而终止。

XIO:  fatal IO error 25 (Inappropriate ioctl for device) on X server "localhost:10.0"^M
257706       after 507 requests (507 known processed) with 5 events remaining.^M
257707 0.4.38,23): recv 'x01159454   r28 

I am using matplotlib to plot the graph and this is the first time I am using this lib.我正在使用 matplotlib 绘制图形,这是我第一次使用这个库。 Since the error indicates X server issue I believe its related to matplot lib becuase other wise its pure telnet script and there is no role of X server anywhere in the script由于错误表明 X 服务器问题,我认为它与 matplot lib 相关,因为其他方面它是纯 telnet 脚本,并且脚本中的任何地方都没有 X 服务器的作用

Even with the matplot lib my goal is to save the graph as png image.即使使用 matplot lib,我的目标也是将图形保存为 png 图像。

Below is my code for matplot lib, please see if anything obviously wrong with it.下面是我的 matplot lib 代码,请看看它是否有明显的错误。

 15 plt.ioff()
 16
 17 def plot_cpu_utilization_graphs(df):
 18     plt.clf()
 19     column_name = 'CPU'
 20     #df = df[[column_name, 'timestamp', 'ip']]
 21     max_value = df[column_name].max()
 22     if max_value < 100:
 23          max_value = 100
 24     min_value = df[column_name].min()
 25     if min_value > 0:
 26         min_value = 0
 27     start_idx = df['timestamp'].iloc[0]
 28     end_idx = df['timestamp'].iloc[-1]
 29     time_series = pandas.DatetimeIndex(freq='20T', start=start_idx, end=end_idx)
 30     y_axes_series = range(int(min_value), int(max_value), 10)
 31     #ax = df.groupby('ip').plot(x='timestamp', y='CPU')
 32     fig, ax = plt.subplots()
 33     labels = []
 34     for key, grp in df.groupby(['ip']):
 35         ax = grp.plot(x='timestamp', y='CPU', ax=ax )
 36         labels.append(key)
 37     lines, _ = ax.get_legend_handles_labels()
 38     lgd = ax.legend(lines, labels, loc='upper center', bbox_to_anchor=(-.25, 1))
 39     ax.set_ylabel("CPU")
 40     ax.set_xlabel("Time")
 41     ax.set_ylim(min_value, max_value)
 42     #ax.set_xlim(time_series[0], time_series[-1])
 43     plt.title("CPU STATS")
 44     fig.savefig('CPUStats', bbox_extra_artists=(lgd,), bbox_inches='tight')



 74 def reboot_count(df):
 75     plt.clf()
 76     plt.cla()
 77     sf = df[df.Rebooted][['ip', 'Rebooted']].groupby(['ip', 'Rebooted']).agg(len)
 78     if not sf.empty:
 79         new_df = pandas.DataFrame({"ip":sf.index.levels[0], "Reboot Count":sf.values})
 80         p = new_df.plot(kind='bar', x='ip', y='Reboot Count', color='grey')
 81
 82         ax = p.axes
 83         for tick in ax.get_xticklabels():
 84            tick.set_rotation(15)
 85         ax.set_ylabel("Reboot Count")
 86         ax.set_xlabel("IP")
 87         #ax.legend().remove()
 88         plt.title(" REBOOT COUNTS")
 89         plt.savefig('Reboot Counts')
 90     else:
 91         print "No Data Present for Graphs"

I had the same error.我有同样的错误。 The error is due the backend that matplotlib is using (you are running it in a non-interactive mode)错误是由于matplotlib正在使用的后端(您在非交互模式下运行它)

try尝试

import matplotlib
matplotlib.use('Agg') 

See https://matplotlib.org/faq/howto_faq.htmlhttps://matplotlib.org/faq/howto_faq.html

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

相关问题 IOError:[Errno 25] 设备的 ioctl 不合适 - IOError: [Errno 25] Inappropriate ioctl for device 键盘和弦代码的错误消息:termios.error: (25, 'Inappropriate ioctl for device') - Error message for keyboard-chord code: termios.error: (25, 'Inappropriate ioctl for device') 詹金斯的pipenv shell返回问题termios.error:(25,&#39;不合适的设备ioctl&#39;) - pipenv shell in Jenkins return the issue termios.error: (25, 'Inappropriate ioctl for device') 崇高的tset:标准错误:设备的ioctl不适当 - Sublime tset: standard error: Inappropriate ioctl for device Pexpect和PyCharm - 适用于设备的ioctl - Pexpect and PyCharm - Inappropriate ioctl for device OpenCV3错误:“无法停止流:设备的不适当的ioctl” - OpenCV3 error: “Unable to stop the stream: Inappropriate ioctl for device” 如何抑制“stty:'标准输入':设备的 ioctl 不合适”错误 - How to supress the “stty: 'standard input': Inappropriate ioctl for device” error opencv无法阻止流:设备的ioctl不合适 - opencv Unable to stop the stream: Inappropriate ioctl for device 在Python中运行ioctl会返回ENOTTY-设备不适合的ioctl - Running ioctl in Python returns ENOTTY - inappropriate ioctl for device 清除第二组X刻度matplot lib - Clearing second set of X ticks matplot lib
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM