【发布时间】:2021-08-30 17:15:57
【问题描述】:
我使用 pyinstaller 创建了一个 .exe 文件。当我在 Pycharm 上运行它时,它运行良好。 但是当我尝试运行可执行文件时会发生错误。
这是完整的错误:
Traceback (most recent call last):
File "DT_070621.py", line 397, in <module>
File "DT_070621.py", line 315, in arquivos_saida
File "pandas\plotting\_core.py", line 892, in __call__
File "pandas\plotting\_core.py", line 1814, in _get_plot_backend
File "pandas\plotting\_core.py", line 1754, in _load_backend
ImportError: matplotlib is required for plotting when the default backend "matplotlib" is selected.
[11304] Failed to execute script 'DT_070621' due to unhandled exception!
但是当我检查 matplotlib 版本时,一切似乎都很好。
>>> import matplotlib
>>> matplotlib.__version__
'3.4.3'
我还检查了正在使用的后端:
>>> import matplotlib.pyplot as plt
>>> plt.get_backend()
'TkAgg'
我也尝试过像这样创建 .exe 文件:
pyinstaller --hidden-import=openpyxl --hidden-import=matplotlib --onefile DT_070621.py
但这并没有解决我的问题。
我还查看了this question,但它的描述似乎不完整,并且没有任何答案可以帮助我解决这个问题。
这是我脚本中的导入:
import xml.etree.ElementTree as ET
from xml.etree import ElementTree
import pandas as pd
from shapely.geometry import Point, Polygon
import numpy as np
import matplotlib.pyplot as plt
import os
发生了什么,我该如何解决?
【问题讨论】:
-
这能回答你的问题吗? ImportError with Pyinstaller and Pandas
-
谢谢,但我不这么认为。
标签: python matplotlib pyinstaller