Python3在Ubuntu上绘图时出现分段错误
以下代码在Windows 10(Python 3.7.4)上运行良好,但在Ubuntu 19.2上打印时(Python 3.6.8)会出现“分段错误(内核转储)”:Python3在Ubuntu上绘图时出现分段错误,python,pandas,flask,Python,Pandas,Flask,以下代码在Windows 10(Python 3.7.4)上运行良好,但在Ubuntu 19.2上打印时(Python 3.6.8)会出现“分段错误(内核转储)”: 从flask导入flask、请求、呈现\u模板、重定向、发送\u文件 作为pd进口熊猫 导入操作系统、psutil、数学、子流程 .... @应用程序路径('/plott/d/')) def绘图仪TD(n,dp): dft=dft[dft.dp.eq(dp)] 如果dft.shape[0]>=2: dft['value']=dft[
从flask导入flask、请求、呈现\u模板、重定向、发送\u文件
作为pd进口熊猫
导入操作系统、psutil、数学、子流程
....
@应用程序路径('/plott/d/'))
def绘图仪TD(n,dp):
dft=dft[dft.dp.eq(dp)]
如果dft.shape[0]>=2:
dft['value']=dft['value'].aType(浮点)
plot\u fig=dft.plot(x='timestamp',y='value',kind='line',title=“test”)
绘图图网格(“打开”)
fn='static/'+str(dp)+'.png'
绘图图获取图()保存图(fn)
返回发送文件(fn,mimetype='image/png')
返回“plott/d值不足”+str(dp)
....
我将ubuntu客户端上的所有python模块更新为:
Python 3.7.5::
烧瓶(1.1.1)
调度程序(1.11.0)
摇瓶棉花糖(0.10.1)
炼金术(2.4.1)
....
大熊猫(0.25.3)
....
枕头(6.2.1)
现在它开始工作了
from flask import Flask, request, render_template, redirect, send_file
import pandas as pd
import os, psutil, math, subprocess
....
@app.route('/plott/d/<n>/<dp>')
def plottd(n,dp):
dft = dft[dft.dp.eq(dp)]
if dft.shape[0] >= 2:
dft['value'] = dft['value'].astype(float)
plot_fig = dft.plot(x='timestamp',y='value', kind = 'line', title="test")
plot_fig.grid('on')
fn = 'static/'+str(dp)+'.png'
plot_fig.get_figure().savefig(fn)
return send_file(fn, mimetype='image/png')
return "not enough values for plott/d " + str(dp)
....