【问题标题】:Python exectuable: FileNotFoundError: [Errno 2]: No such file or directory matplotlibrcPython可执行文件:FileNotFoundError:[Errno 2]:没有这样的文件或目录matplotlibrc
【发布时间】:2021-09-19 17:42:43
【问题描述】:

我有一个想要转换为可执行文件的 python 脚本。它使用了 matplotlib 模块,这显然是导致问题的原因。我用“pyinstaller --onefile file.py”创建了exe文件。当我打开 distr 文件夹中的 .exe 文件时,它会显示如下内容,然后立即关闭:

很抱歉发布了一张图片,但我必须记录屏幕才能真正看到消息(我不太喜欢编程以了解其他方式)

我的程序代码如下:

OPTION=input("Corriente de salida del prefraccionador es destilado o residuo? (D/R)")

from pylab import*

WF=100
xZ=0.68
WE=50
xF=0.2
xF2=[0.0]*10

ZNA1=0.3
ZNA2=0.4
ZNA3=0.6
T1BB=350
T1BD=320
T2BB=350
T2BD=320


DSEA=[0.0]*len(xF2)
DSEB=[0.0]*len(xF2)
for i in range (0,10,1):
    if OPTION=="D":
        xF2[i] = i / 10
        WA1D = WF * (xZ - xF2[i]) / xZ
        WA1B = WF - WA1D
        WA2D = WA1B * xZ
        WA2B = WA1B + WE - WA2D
        WA3B = WA2B - WA1B * (1 - xZ)
        WA3D = WA2B - WA3B
        EDA1 = WA1D * ZNA1
        EDA2 = WA2D * ZNA2
        EDA3 = WA3D * ZNA3
        DSEA[i] = (EDA1 + EDA2 + EDA3) / (WF)
    else:
        xF2[i] = i / 10
        WA1B = WF * (xZ - xF2[i]) / xZ
        WA1D = WF - WA1B
        WA2D = WA1B * xZ
        WA2B = WA1B + WE - WA2D
        WA3B = WA2B - WA1B * (1 - xZ)
        WA3D = WA2B - WA3B
        EBA1 = WA1B
        EDA2 = WA2D * ZNA2
        EDA3 = WA3D * ZNA3
        DSEA[i] = (EBA1 + EDA2 + EDA3) / (WF)


    # 2 COLUMNAS
    # Caudales
    WB2B = WE
    WB1B = WF * (1 - xF2[i]) + WB2B
    WB1D = WF * xF2[i]
    WB2D = WB1B - WB2B
    # Eficacias de carnot
    ZNB1 = (T1BB - T1BD) / T1BB
    ZNB2 = (T2BB - T2BD) / T2BB
    # Eficacias de columna
    EDB1 = WB1D * ZNB1
    EDB2 = WB2D * ZNB2
    # DSEB
    DSEB[i] = (EDB1 + EDB2) / (WF)
xFL=[xF,xF]
xFT=[0,1]
plt.ylabel="DSE"
plt.xlabel="Fraccio molar entrada"
#plt.plot(x,y)
plt.plot(xF2,DSEA)
plt.plot(xF2,DSEB)
plt.plot(xFL,xFT)
plt.legend(["Amb prefraccionador","Sense prefraccionador","Composició entrada"])
plt.show()

如果您想尝试,它应该为输入“D”(无关)显示以下图:

我已经编写了另外两个程序,但没有导入任何模块来查看是否是问题所在,并且 .exe 和 .py 文件都按预期工作(其中一个甚至有一个可以正常工作的 tkinter GUI)在他们的计算机上是写在另一个没有安装python的。

我已经搜索了与此错误相关的帖子,但我找不到解决方案,因为它们都与普通 .py 文件失败有关,这不是我的情况,因为我的 .py 文件正在工作。

提前致谢

【问题讨论】:

    标签: python matplotlib pyinstaller


    【解决方案1】:

    我遇到了同样的问题。 I found the solution here。 问题是 pyinstaller 和 onefile 的版本不能一起工作。 使用

    pip install --upgrade pyinstaller

    在终端中,它应该可以工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-13
      • 1970-01-01
      • 1970-01-01
      • 2018-01-24
      • 1970-01-01
      • 2022-11-13
      • 2019-11-03
      相关资源
      最近更新 更多