C++ Microsoft Visual C++;运行时库:运行时错误
我在运行python程序时遇到了一个问题。错误提示粘贴在下面。 我在代码中使用matplotlib.pyplot lib来实现实时拓扑图。该程序可以成功运行,但每次我拖动绘图窗口时,都会跳出错误。我不知道怎么修理它。请给我一些建议,谢谢和问候 错误显示:C++ Microsoft Visual C++;运行时库:运行时错误,c++,python,matplotlib,runtime,C++,Python,Matplotlib,Runtime,我在运行python程序时遇到了一个问题。错误提示粘贴在下面。 我在代码中使用matplotlib.pyplot lib来实现实时拓扑图。该程序可以成功运行,但每次我拖动绘图窗口时,都会跳出错误。我不知道怎么修理它。请给我一些建议,谢谢和问候 错误显示: Rumtime Error! Program:D:\academic software\Python\pythonw.exe This application has requested the Runtime to terminate it
Rumtime Error!
Program:D:\academic software\Python\pythonw.exe
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
代码:
from socket import *
from time import ctime
from binascii import *
from sys import *
from d_deal import *
from d_trans import *
import sys
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
from threading import *
import networkx as nx
import matplotlib.pyplot as plt
from frame import *
app = QtGui.QApplication([])
plt.ion()
#define the global variables
link=[]
link_list=[] #the list of the links
link_loss=[] #the loss time of the relevant links
link_flags=[] #the flag of whether del the link
global g
g=nx.Graph()
plt.figure("topology",figsize=(6,6),facecolor='white')
def tp_dorule():
global f,link_list
link_flag=1
link_flag_sd=1
link_flag_so=1
if f.sour==f.orig:
for i in range(len(link_list)):
if (f.sour,f.dest)==link_list[i] or (f.dest,f.sour)==link_list[i]:
link_flag=0
if link_flag==1:
link_list.append((f.sour,f.dest))
link_loss.append(0)
link_flags.append(1)
else:
for i in range(len(link_list)):
if (f.sour,f.dest)==link_list[i] or (f.dest,f.sour)==link_list[i]:
link_flag_sd=0
for j in range(len(link_list)):
if (f.sour,f.orig)==link_list[j] or (f.orig,f.sour)==link_list[j]:
link_flag_so=0
if link_flag_sd==1:
link_list.append((f.sour,f.dest))
link_loss.append(0)
link_flags.append(1)
if link_flag_so==1:
link_list.append((f.sour,f.orig))
link_loss.append(0)
link_flags.append(1)
print link_list
for i in range(len(link_list)):
if (f.sour,f.dest)!=link_list[i] and (f.dest,f.sour)!=link_list[i] and (f.orig,f.dest)!=link_list[i] and (f.dest,f.orig)!=link_list[i]:
link_loss[i]+=1
else:
link_loss[i]=0
print link_loss
def tp_update():
global g,link_list
plt.clf()
link=[]
for i in range(len(link_loss)):
if link_loss[i]>=2:
link_flags[i]=0
for i in range(len(link_flags)):
if link_flags[i]!=0:
link.append(link_list[i])
print link
g.add_edges_from(link)
pos=nx.spectral_layout(g)
nx.draw(g,pos,with_labels=True,node_size=500)
plt.draw()
def update():
tp_update()
####the timer interrupte
timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(1000)
####the data dealing part
def data_deal():
print '2'
#set the udp transportation parameters
HOST = '127.0.0.1'
PORT = 1031
BUFSIZ = 2048
ADDR = (HOST, PORT)
#the pid debug text
PID=os.getpid()
file=open("PID.txt",'w')
file.write(str(PID))
file.close()
#binding the udp address
udpSerSock = socket(AF_INET, SOCK_DGRAM)
udpSerSock.bind(ADDR)
#the main function
while True:
#receive the raw data
raw_data,addr=udpSerSock.recvfrom(BUFSIZ)
if not raw_data:
continue
##dealing with the raw_data(not solute yet)
data=hexlify(raw_data)
print data
global f
f=data_dealing(data)
data_trans(f)
print '1'
if f.ftype != 'else frame' and f.ftype != 'ack frame':
tp_dorule()
th2 = Thread(target=data_deal)
th2.start()
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
sys.exit(app.instance().exec_())
为什么是C++标签?我们能看看你的密码吗?或者一个最小的例子做同样的事情?我不知道为什么,但错误窗口的标题说它…我刚刚粘贴了代码,它可以正常运行,没有其他问题,除了我在问题中描述的问题。我期待着你的答复,慢慢来。感谢您的热情和评论!