python 可启动的.exe文件需要10分钟才能启动

2cmtqfgy  于 2023-04-19  发布在  Python
关注(0)|答案(1)|浏览(130)

我使用PyQt 5在python上创建了一个应用程序,并使用PyInstaller创建了一个可启动的文件,使用的是onefile方法。(但我不记得我当时使用的代码**edit onedir).我把这一点的面值假设几十个包,3个python文件包括在内,和几千行被迫缓慢 Boot 这个应用程序,但看看其他论坛的问题,我不再那么肯定。我还试图在SSL上启动应用程序,这会阻止我安装软件包,所以我很好奇可启动程序是否试图一遍又一遍地安装软件包,直到失败,然后按原样打开应用程序。我对此感到难以置信的困惑,任何见解都会有帮助。
编辑:

from PyQt5 import Qt, QtCore, QtGui, QtWidgets
# from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (QWidget, QLabel, QHBoxLayout, QVBoxLayout, QTabWidget,
                             QGridLayout)
from superqt import QLabeledRangeSlider

from scipy import integrate
import numpy as np
import pandas as pd
import math
# from openpyxl import load_workbook
from matplotlib import ticker
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon

from scipy.interpolate import interp1d

import superqt
# from sklearn.metrics import r2_score

from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar

class Graph_5(QWidget):
    def __init__(self):
        super().__init__()
        self.bing = 0
        self.init_graph()
        self.init_layout()

def init_graph(self):
    self.plus = QtWidgets.QPushButton("+")
    self.plus.setMaximumHeight(16777214)
    self.plus.setStyleSheet("border :3px solid black")
    self.plus.clicked.connect(self.addcanvas)
    self.minus = QtWidgets.QPushButton("-")
    self.minus.setMaximumHeight(16777214)
    self.minus.setStyleSheet("border :3px solid black")
    self.minus.clicked.connect(self.removecanvas)

    self.slider = QLabeledRangeSlider(QtCore.Qt.Orientation.Vertical)
    self.slider.setFixedHeight(250)
    self.slider.setTickPosition(QtWidgets.QSlider.TicksLeft)
    self.slider.setRange(0,2)
    self.slider.setValue([0,2])
    self.slider.setTickInterval(1)
    self.slider.valueChanged.connect(self.change_figure)
    
    self.checkBtn_2D = QtWidgets.QCheckBox("2D")
    self.checkBtn_2D.stateChanged.connect(lambda: self.ChckBox_2_Processor(1))
    self.checkBtn_3D = QtWidgets.QCheckBox("3D")
    self.checkBtn_3D.stateChanged.connect(lambda: self.ChckBox_3_Processor(1))
    
    self.left_frame = Qt.QFrame()
    self.left_frame.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
    self.left_frame.setFrameStyle(Qt.QFrame.WinPanel | Qt.QFrame.Raised)
    self.left_frame.setLineWidth(2)
    self.poly_lft = QtWidgets.QCheckBox("6th Polynomial")
    self.poly_lft.clicked.connect(self.change_figure)
    
    self.actual_lft = QtWidgets.QCheckBox("Actual Data")
    self.actual_lft.clicked.connect(self.change_figure)
    
    self.centroids_lft = QtWidgets.QCheckBox("Centroids")
    self.centroids_lft.clicked.connect(self.change_figure)
    self.fill_lft = QtWidgets.QCheckBox("Fill")
    self.fill_lft.clicked.connect(self.change_figure)
    
    self.centroids_real_lft = QtWidgets.QCheckBox("Centroids")
    self.centroids_real_lft.clicked.connect(self.change_figure)
    self.fill_real_lft = QtWidgets.QCheckBox("Fill")
    self.fill_real_lft.clicked.connect(self.change_figure)
    
    frame_lay = QGridLayout(self.left_frame)
    frame_lay.addWidget(self.actual_lft,0,0,1,2)
    frame_lay.addWidget(self.centroids_real_lft,1,1)
    frame_lay.addWidget(self.fill_real_lft,2,1)
    frame_lay.addWidget(self.poly_lft,3,0,1,2)
    frame_lay.addWidget(self.centroids_lft,4,1)
    frame_lay.addWidget(self.fill_lft,5,1)

    self.right_frame = Qt.QFrame()
    self.right_frame.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
    self.right_frame.setFrameStyle(Qt.QFrame.WinPanel | Qt.QFrame.Raised)
    self.right_frame.setLineWidth(2)
    self.poly_rght = QtWidgets.QCheckBox("6th Polynomial")
    self.poly_rght.clicked.connect(self.change_fig_2)
    
    self.actual_rght = QtWidgets.QCheckBox("Actual Data")
    self.actual_rght.clicked.connect(self.change_fig_2)
    
    self.centroids_rght = QtWidgets.QCheckBox("Centroids")
    self.centroids_rght.clicked.connect(self.change_fig_2)
    self.fill_rght = QtWidgets.QCheckBox("Fill")
    self.fill_rght.clicked.connect(self.change_fig_2)
    
    self.centroids_real_rght = QtWidgets.QCheckBox("Centroids")
    self.centroids_real_rght.clicked.connect(self.change_fig_2)
    self.fill_real_rght = QtWidgets.QCheckBox("Fill")
    self.fill_real_rght.clicked.connect(self.change_fig_2)
    
    frame_lay = QGridLayout(self.right_frame)
    frame_lay.addWidget(self.actual_rght,0,0,1,2)
    frame_lay.addWidget(self.centroids_real_rght,1,1)
    frame_lay.addWidget(self.fill_real_rght,2,1)
    frame_lay.addWidget(self.poly_rght,3,0,1,2)
    frame_lay.addWidget(self.centroids_rght,4,1)
    frame_lay.addWidget(self.fill_rght,5,1)
    
    
    self.fig = plt.figure()
    self.canvas = FigureCanvas(self.fig)
    self.toolbar = NavigationToolbar(self.canvas, self)
    
    self.slider_right = QLabeledRangeSlider(QtCore.Qt.Orientation.Vertical)
    self.slider_right.setFixedHeight(250)
    self.slider_right.setTickPosition(QtWidgets.QSlider.TicksLeft)
    self.slider_right.setRange(0,2)
    self.slider_right.setValue([0,2])
    self.slider_right.setTickInterval(1)
    self.slider_right.valueChanged.connect(self.change_fig_2)
    
    self.checkright_2D = QtWidgets.QCheckBox("2D")
    self.checkright_2D.stateChanged.connect(lambda: self.ChckBox_2_Processor(2))
    self.checkright_3D = QtWidgets.QCheckBox("3D")
    self.checkright_3D.stateChanged.connect(lambda: self.ChckBox_3_Processor(2))
    
    self.fig_2 = plt.figure()
    self.canvas_2 = FigureCanvas(self.fig_2)
    self.toolbar_2 = NavigationToolbar(self.canvas_2, self)
    
    self.tableWidget = QtWidgets.QTableWidget()
    self.tableWidget.setMaximumHeight(120)
    
def init_layout(self):
    side_1 = QGridLayout()
    side_1.addWidget(self.checkBtn_2D,0,0)
    side_1.addWidget(self.checkBtn_3D,0,1)
    side_1.addWidget(self.left_frame,1,0,1,2)
    side_1.addWidget(self.slider,2,0,1,2)
    graph_lay = QVBoxLayout()
    graph_lay.addWidget(self.toolbar)
    graph_lay.addWidget(self.canvas)
    
    self.parent_widg_1 = QLabel()
    self.parent_widg_1.lay = QHBoxLayout(self.parent_widg_1)
    self.parent_widg_1.lay.addLayout(side_1)
    self.parent_widg_1.lay.addLayout(graph_lay)
    
    side_2 = QGridLayout()
    side_2.addWidget(self.checkright_2D,0,0)
    side_2.addWidget(self.checkright_3D,0,1)
    side_2.addWidget(self.right_frame,1,0,1,2)
    side_2.addWidget(self.slider_right,2,0,1,2)
    graph_lay_2 = QVBoxLayout()
    graph_lay_2.addWidget(self.toolbar_2)
    graph_lay_2.addWidget(self.canvas_2)
    
    self.parent_widg_2 = QLabel()
    self.graph_lay_right = QHBoxLayout(self.parent_widg_2)
    self.graph_lay_right.addLayout(graph_lay_2)
    self.graph_lay_right.addLayout(side_2)
    self.parent_widg_2.hide()
    
    
    add_subtract = QVBoxLayout()
    add_subtract.addWidget(self.plus)
    add_subtract.addWidget(self.minus)
    
    visual_lay = QHBoxLayout()
    visual_lay.addLayout(add_subtract)
    visual_lay.addWidget(self.parent_widg_1)
    visual_lay.addWidget(self.parent_widg_2)
    
    total_lay = QVBoxLayout()
    total_lay.addLayout(visual_lay)
    total_lay.addWidget(self.tableWidget)
    self.setLayout(total_lay)

def removecanvas(self):
    if self.canvas_2.isVisible():
        self.parent_widg_2.hide()
        return
    elif self.canvas.isVisible():
        self.parent_widg_1.hide()
    
def addcanvas(self):
    if not self.canvas.isVisible():
        self.parent_widg_1.show()
        return
    elif not self.canvas_2.isVisible():
        self.parent_widg_2.show()
        
def reset_clicked(self):
    if self.canvas_2.isVisible():
        self.parent_widg_2.hide()
    
    elif not self.canvas.isVisible():
        self.parent_widg_1.show()
        
    self.fig.clear()
    self.fig_2.clear()
    self.canvas.draw()
    self.canvas_2.draw()
    
    self.slider_right.setRange(0,2)
    self.slider_right.setValue([0,2])
    self.slider_right.setTickInterval(1)
    self.slider.setRange(0,2)
    self.slider.setValue([0,2])
    self.slider.setTickInterval(1)
    
    self.poly_rght.setCheckState(False)
    self.actual_rght.setCheckState(False)
    self.centroids_rght.setCheckState(False)
    self.fill_rght.setCheckState(False)
    self.centroids_real_rght.setCheckState(False)
    self.fill_real_rght.setCheckState(False)
    
    self.poly_lft.setCheckState(False)
    self.actual_lft.setCheckState(False)
    self.centroids_lft.setCheckState(False)
    self.fill_lft.setCheckState(False)
    self.centroids_real_lft.setCheckState(False)
    self.fill_real_lft.setCheckState(False)
    
    self.checkBtn_2D.setCheckState(False)
    self.checkBtn_3D.setCheckState(False)
    self.checkright_2D.setCheckState(False)
    self.checkright_3D.setCheckState(False)
    
    self.tableWidget.clear()
    
    try:
        del self.x_vals
        del self.col_titles
        del self.dicti
        del self.rng
    except AttributeError:
        return
    

def ChckBox_2_Processor(self, canv_ID):
    if canv_ID == 1:
        if self.checkBtn_2D.isChecked() and self.checkBtn_3D.isChecked():
            self.update_2Dfig(333,canv_ID)
            try:
                self.ax_3D_1.title.set_text("3D Plot of Pressure against Distance")
                self.ax_3D_1.set_xlabel("distance from vent [ft]")
                self.ax_3D_1.set_ylabel("Time [mins]")
                self.ax_3D_1.set_zlabel("Measured Pressure")
                self.canvas.draw()
            except AttributeError:
                True
        elif self.checkBtn_2D.isChecked() and not self.checkBtn_3D.isChecked():
            self.update_2Dfig(111,canv_ID)
            try:
                self.ax_2D_1.title.set_text("2D Plot of Pressure against Distance")
                self.ax_2D_1.set_xlabel("distance from vent [ft]")
                self.ax_2D_1.set_ylabel("Measured Pressure")
                self.canvas.draw()
                # print(self.ax_2D_1)
            except AttributeError:
                True
                
        elif not self.checkBtn_2D.isChecked() and self.checkBtn_3D.isChecked():
            self.fig.clear()
            self.update_3Dfig(111,canv_ID)
            try:
                self.ax_3D_1.title.set_text("3D Plot of Pressure against Distance")
                self.ax_3D_1.set_xlabel("distance from vent [ft]")
                self.ax_3D_1.set_ylabel("Time [mins]")
                self.ax_3D_1.set_zlabel("Measured Pressure")
                self.canvas.draw()
            except AttributeError:
                True
        elif not self.checkBtn_2D.isChecked() and not self.checkBtn_3D.isChecked():
            self.fig.clear()
            self.canvas.draw()
    
    elif canv_ID == 2:
        if self.checkright_2D.isChecked() and self.checkright_3D.isChecked():
            self.update_2Dfig(333,canv_ID)
            try:
                self.ax_3D_2.title.set_text("3D Plot of Pressure against Distance")
                self.ax_3D_2.set_xlabel("distance from vent [ft]")
                self.ax_3D_2.set_ylabel("Time [mins]")
                self.ax_3D_2.set_zlabel("Measured Pressure")
                self.canvas_2.draw()
            except AttributeError:
                True
        elif self.checkright_2D.isChecked() and not self.checkright_3D.isChecked():
            self.update_2Dfig(111,canv_ID)
            try:
                self.ax_2D_2.title.set_text("2D Plot of Pressure against Distance")
                self.ax_2D_2.set_xlabel("distance from vent [ft]")
                self.ax_2D_2.set_ylabel("Measured Pressure")
                self.canvas_2.draw()
            except AttributeError:
                True
        elif not self.checkright_2D.isChecked() and self.checkright_3D.isChecked():
            self.fig_2.clear()
            self.update_3Dfig(111,canv_ID)
            try:
                self.ax_3D_2.title.set_text("3D Plot of Pressure against Distance")
                self.ax_3D_2.set_xlabel("distance from vent [ft]")
                self.ax_3D_2.set_ylabel("Time [mins]")
                self.ax_3D_2.set_zlabel("Measured Pressure")
                self.canvas_2.draw()
            except AttributeError:
                True
        elif not self.checkright_2D.isChecked() and not self.checkright_3D.isChecked():
            self.fig_2.clear()
            self.canvas_2.draw()      
        
    
def ChckBox_3_Processor(self, canv_ID):
    if canv_ID == 1:
        if self.checkBtn_3D.isChecked() and self.checkBtn_2D.isChecked():
            self.update_3Dfig(333,canv_ID)
            try:
                self.ax_2D_1.title.set_text("2D Plot of Pressure against Distance")
                self.ax_2D_1.set_xlabel("distance from vent [ft]")
                self.ax_2D_1.set_ylabel("Measured Pressure")
                self.canvas.draw()
            except AttributeError:
                True
        elif self.checkBtn_3D.isChecked() and not self.checkBtn_2D.isChecked():
            self.update_3Dfig(111,canv_ID)
            try:
                self.ax_3D_1.title.set_text("3D Plot of Pressure against Distance")
                self.ax_3D_1.set_xlabel("distance from vent [ft]")
                self.ax_3D_1.set_ylabel("Time [mins]")
                self.ax_3D_1.set_zlabel("Measured Pressure")
                self.canvas.draw()
            except AttributeError:
                True
        elif not self.checkBtn_3D.isChecked() and self.checkBtn_2D.isChecked():
            self.fig.clear()
            self.update_2Dfig(111,canv_ID)
            try:
                self.ax_2D_1.title.set_text("2D Plot of Pressure against Distance")
                self.ax_2D_1.set_xlabel("distance from vent [ft]")
                self.ax_2D_1.set_ylabel("Measured Pressure")
                self.canvas.draw()
            except AttributeError:
                True
        elif not self.checkBtn_2D.isChecked() and not self.checkBtn_3D.isChecked():
            self.fig.clear()
            self.canvas.draw()
        
    elif canv_ID == 2:
        if self.checkright_3D.isChecked() and self.checkright_2D.isChecked():
            self.update_3Dfig(333,canv_ID)
            try:
                self.ax_2D_2.title.set_text("2D Plot of Pressure against Distance")
                self.ax_2D_2.set_xlabel("distance from vent [ft]")
                self.ax_2D_2.set_ylabel("Measured Pressure")
                self.canvas_2.draw()
            except AttributeError:
                True
        elif self.checkright_3D.isChecked() and not self.checkright_2D.isChecked():
            self.update_3Dfig(111,canv_ID)
            try:
                self.ax_3D_2.title.set_text("3D Plot of Pressure against Distance")
                self.ax_3D_2.set_xlabel("distance from vent [ft]")
                self.ax_3D_2.set_ylabel("Time [mins]")
                self.ax_3D_2.set_zlabel("Measured Pressure")
                self.canvas_2.draw()
            except AttributeError:
                True
        elif not self.checkright_3D.isChecked() and self.checkright_2D.isChecked():
            self.fig_2.clear()
            self.update_2Dfig(111,canv_ID)
            try:
                self.ax_2D_2.title.set_text("2D Plot of Pressure against Distance")
                self.ax_2D_2.set_xlabel("distance from vent [ft]")
                self.ax_2D_2.set_ylabel("Measured Pressure")
                self.canvas_2.draw()
            except AttributeError:
                True
        elif not self.checkright_2D.isChecked() and not self.checkright_3D.isChecked():
            self.fig_2.clear()
            self.canvas_2.draw()
        
    

def update_2Dfig(self,subplot,canv_ID):
    try: self.dicti
    except AttributeError:
        return
    
    if canv_ID == 1:
        self.ax_2D_1 = self.fig.add_subplot(subplot)
        self.change_figure()
    elif canv_ID ==2:
        self.ax_2D_2 = self.fig_2.add_subplot(subplot)
        self.change_fig_2()

    
def update_3Dfig(self,subplot,canv_ID):
    try: self.dicti
    except AttributeError:
        return
    
    if canv_ID == 1:
        self.ax_3D_1 = self.fig.add_subplot(subplot,projection = '3d')
        self.change_figure()
    elif canv_ID == 2:
        self.ax_3D_2 = self.fig_2.add_subplot(subplot,projection = '3d')
        self.change_fig_2()
    
    
def change_figure(self):
    try: self.dicti
    except AttributeError:
        return
    try:
        self.ax_2D_1.clear()
    except AttributeError:
        try:
            self.ax_3D_1.clear()
        except AttributeError:
            return
    else:
        try:
            self.ax_3D_1.clear()
        except AttributeError:
            True
            
    plotting_data = []
    plotting_time = []
    plotting_dist = []
    
    plotting_data_rl = []
    plotting_time_rl = []
    plotting_dist_rl = []
    
    P_vals = {}
    T_vals = {}
    for i in range(self.slider.value()[0],self.slider.value()[1]+1):
        P_vals[i] = list()
        T_vals[i] = list()
        
        for j in self.col_titles:
            if j.lower() == 'time' or j.lower() == 'x':
                continue
            P_vals[i].append(self.dicti[j][i])
            T_vals[i].append(self.dicti[j][i])
        
        x=np.linspace(min(self.x_vals),max(self.x_vals),100)
        poly = np.polyfit(self.x_vals, P_vals[i], deg=6)
        data_fit = np.poly1d(poly)(x)
        x_bar = self.do_the_math_dummy(x,data_fit)
        x_bar_real = self.do_the_math_dummy(self.x_vals,P_vals[i])
        
        
        for j in range(0,100): plotting_time.append(i)
        for j in x: plotting_dist.append(j)
        for j in data_fit: plotting_data.append(j)
        
        for j in range(0,len(self.x_vals)): plotting_time_rl.append(i)
        for j in self.x_vals: plotting_dist_rl.append(j)
        for j in P_vals[i]: plotting_data_rl.append(j)
    
        if self.poly_lft.isChecked() and not self.fill_lft.isChecked():
            try:
                self.ax_2D_1.plot(x,data_fit)
            except AttributeError:
                self.ax_3D_1.plot(x,[i]*len(x),data_fit)          
            else:
                try:
                    self.ax_3D_1.plot(x,[i]*len(x),data_fit) 
                except AttributeError:
                    True
        if self.actual_lft.isChecked() and not self.fill_real_lft.isChecked():
            try:
                self.ax_2D_1.plot(self.x_vals, P_vals[i],'o--')
            except AttributeError:
                self.ax_3D_1.plot(self.x_vals,[i]*len(self.x_vals),P_vals[i],'o--')      
            else:
                try:
                    self.ax_3D_1.plot(self.x_vals,[i]*len(self.x_vals),P_vals[i],'o--')
                except AttributeError:
                    True
        if self.centroids_lft.isChecked():
            try:
                self.ax_2D_1.plot([x_bar],[max(data_fit)], '-o')
            except AttributeError:
                self.ax_3D_1.plot([x_bar],[i],[max(data_fit)], '-o')            
            else:
                try:
                    self.ax_3D_1.plot([x_bar],[i],[max(data_fit)], '-o')     
                except AttributeError:
                    True
        if self.centroids_real_lft.isChecked():
            try:
                self.ax_2D_1.plot([x_bar_real],[max(P_vals[i])], '-o')
            except AttributeError:
                self.ax_3D_1.plot([x_bar_real],[i],[max(P_vals[i])], '-o')            
            else:
                try:
                    self.ax_3D_1.plot([x_bar_real],[i],[max(P_vals[i])], '-o')     
                except AttributeError:
                    True
    if self.fill_lft.isChecked():
        try:
            # self.ax_2D_1.plot([x_bar],[max(data_fit)], '-o')
            verts = [(x[0], 0)] + list(zip(x, data_fit)) + [(x[len(x)-1], 0)]
            poly = Polygon(verts, facecolor = '0.9', edgecolor = '0.5')
            self.ax_2D_1.add_patch(poly)
        except AttributeError:
            my_cmap = plt.get_cmap('viridis')
            trisurf = self.ax_3D_1.plot_trisurf(plotting_dist,plotting_time,plotting_data,
                         cmap = my_cmap,
                         linewidth = 0.2,
                         antialiased = True,
                         edgecolor = 'grey') 
            # self.ax_3D_1.colorbar(trisurf, ax = self.ax_3D_1, shrink = 0.5, aspect = 5)            
        else:
            try:
                my_cmap = plt.get_cmap('viridis')
                trisurf = self.ax_3D_1.plot_trisurf(plotting_dist,plotting_time,plotting_data,
                             cmap = my_cmap,
                             linewidth = 0.2,
                             antialiased = True,
                             edgecolor = 'grey') 
                # self.ax_3D_1.colorbar(trisurf, ax = self.ax_3D_1, shrink = 0.5, aspect = 5)
            except AttributeError:
                True
    # elif self.fill_lft.isChecked() and self.poly_lft.isChecked() and self.actual_lft.isChecked():
    #     self.fill_lft.setChecked(False)
    if self.fill_real_lft.isChecked():
        try:
            verts = [(self.x_vals[0], 0)] + list(zip(self.x_vals, P_vals[i])) + [(self.x_vals[len(self.x_vals)-1], 0)]
            poly = Polygon(verts, facecolor = '0.9', edgecolor = '0.5')
            self.ax_2D_1.add_patch(poly)
        except AttributeError:
            my_cmap = plt.get_cmap('viridis')
            trisurf = self.ax_3D_1.plot_trisurf(plotting_dist_rl,plotting_time_rl,plotting_data_rl,
                         cmap = my_cmap,
                         linewidth = 0.2,
                         antialiased = True,
                         edgecolor = 'grey') 
            # self.ax_3D_1.colorbar(trisurf, ax = self.ax_3D_1, shrink = 0.5, aspect = 5)            
        else:
            try:
                my_cmap = plt.get_cmap('viridis')
                trisurf = self.ax_3D_1.plot_trisurf(plotting_dist_rl,plotting_time_rl,plotting_data_rl,
                             cmap = my_cmap,
                             linewidth = 0.2,
                             antialiased = True,
                             edgecolor = 'grey') 
                # self.ax_3D_1.colorbar(trisurf, ax = self.ax_3D_1, shrink = 0.5, aspect = 5)
            except AttributeError:
                True
    # elif self.fill_lft.isChecked() and self.poly_lft.isChecked() and self.actual_lft.isChecked():
    #     self.fill_lft.setChecked(False)
    try:
        self.ax_2D_1.set_xticks(self.x_vals)
        self.ax_2D_1.xaxis.set_minor_locator(plt.LinearLocator(10))
        
        self.ax_2D_1.set_yticks(range(0,math.ceil(max(plotting_data_rl)),1))
        self.ax_2D_1.yaxis.set_minor_locator(ticker.AutoMinorLocator(4))
        
        self.ax_2D_1.grid(which='major', color='grey', linewidth=0.8)
        self.ax_2D_1.grid(which='minor', color='red', linestyle=':', linewidth=0.7)
    except AttributeError:
        True
    try:
        self.ax_3D_1.set_xticks(self.x_vals)
        self.ax_3D_1.set_yticks(range(0,max(plotting_time),5))
        self.ax_3D_1.yaxis.set_minor_locator(ticker.AutoMinorLocator(5))
        self.ax_3D_1.set_zticks(range(0,math.ceil(max(plotting_data_rl)),1))
        self.ax_3D_1.zaxis.set_minor_locator(ticker.AutoMinorLocator(4))
        
        self.ax_3D_1.grid(which='major', color='grey', linewidth=0.8)
        self.ax_3D_1.grid(which='minor', color='red', linestyle=':', linewidth=0.7)
    except AttributeError:
        True
    # self.fig.xticks(list(plt.xticks()[0]) + self.x_vals)
    self.canvas.draw()

很抱歉我一开始没有添加代码。考虑到这个问题的范围,我不确定是小样本还是大样本更能充分地洞察我的问题/能力的本质。

wvyml7n5

wvyml7n51#

onefile方法将所有依赖项(动态库和数据)以压缩形式存储在可执行文件中,并在启动应用程序时将其提取到临时文件夹中,这将需要一些时间,具体取决于硬盘驱动器和CPU的速度。
文件在linux上的/tmp或windows上的C:\Users\user\AppData\Local\Temp中提取,但可以更改
简而言之,不要在大型应用程序中使用onefile,或者当你需要快速启动时,你应该使用onedir,以避免提取过程。

相关问题