Issue
I created an .exe file using pyinstaller. When I run it on Pycharm, it works perfectly. But when I try to run the executable an error occurs.
Here's the full error:
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!
But when I check matplotlib version, everything seems fine.
>>> import matplotlib
>>> matplotlib.__version__
'3.4.3'
I've also checked the backend being used:
>>> import matplotlib.pyplot as plt
>>> plt.get_backend()
'TkAgg'
I've also tried creating the .exe file like this:
pyinstaller --hidden-import=openpyxl --hidden-import=matplotlib --onefile DT_070621.py
But it didn't solve my problem.
I've also checked out this question, but its description seems incomplete and there aren't answers that were useful in helping me solve this problem.
Here are the imports in my script:
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
What is going on and how do I solve it?
Solution
Adding --hidden-import pandas.plotting._matplotlib
solved it.
Answered By - Laila Campos
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.