Python3在Ubuntu上绘图时出错

2024-06-16 08:49:29 发布

您现在位置:Python中文网/ 问答频道 /正文

以下代码在Windows 10(Python 3.7.4)上运行良好,但在Ubuntu 19.2的绘图点(Python 3.6.8)上运行时会出现“分段错误(核心转储)”:

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)

....

Tags: 代码importsendreturnplotpngvaluewindows