ydataai / ydata-profiling

1 Line of code data quality profiling & exploratory data analysis for Pandas and Spark DataFrames.
https://docs.profiling.ydata.ai
MIT License
12.45k stars 1.68k forks source link

When importing pandas profiling matplotlib cannot show plots #905

Open diepala opened 2 years ago

diepala commented 2 years ago

Describe the bug

In a jupyter notbook, when importing pandas profiling, matplotlib won't show any plots. This also happens in a normal script. Matplotlib raises the warning UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.. This does not happen if I don't import the pandas profiling.

To Reproduce

In a jupyter notebook, the following code will not show any plots

import matplotlib.pyplot as plt
from pandas_profiling import ProfileReport

plt.plot([1,2,3])

But by removing the second line (from pandas_profiling import ProfileReport) it will behave as expected The bug can also be reproduced in a normal script, by adding plt.show() at the end.

Version information:

Version information is essential in reproducing and resolving bugs. Please report:

Click to expand Version information

``` argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 attrs==21.4.0 autoviz==0.1.35 backcall==0.2.0 black==21.12b0 bleach==4.1.0 blinker==1.4 bokeh==2.4.2 Brlapi==0.8.2 certifi==2020.6.20 cffi==1.15.0 chardet==4.0.0 chrome-gnome-shell==0.0.0 click==7.1.2 colorama==0.4.4 colorcet==3.0.0 command-not-found==0.3 cryptography==3.3.2 cupshelpers==1.0 cycler==0.11.0 dbus-python==1.2.16 debugpy==1.5.1 decorator==5.1.0 defer==1.0.6 defusedxml==0.7.1 distro==1.5.0 emoji==1.6.1 entrypoints==0.3 fonttools==4.28.5 fsspec==0.8.3 hidpidaemon==18.4.6 holoviews==1.14.6 htmlmin==0.1.12 httplib2==0.18.1 hvplot==0.7.3 idna==2.10 ImageHash==4.2.1 importlib-metadata==4.10.0 importlib-resources==5.4.0 ipykernel==6.6.1 ipython==7.31.0 ipython-genutils==0.2.0 ipywidgets==7.6.5 jedi==0.18.1 jeepney==0.7.1 Jinja2==3.0.3 joblib==1.0.1 jsonschema==4.3.3 jupyter==1.0.0 jupyter-client==7.1.0 jupyter-console==6.4.0 jupyter-core==4.9.1 jupyterlab-pygments==0.1.2 jupyterlab-widgets==1.0.2 kernelstub==3.1.4 keyring==23.0.1 kiwisolver==1.3.2 language-selector==0.1 launchpadlib==1.10.13 lazr.restfulclient==0.14.2 lazr.uri==1.0.5 louis==3.18.0 macaroonbakery==1.3.1 Markdown==3.3.6 MarkupSafe==2.0.1 matplotlib==3.5.1 matplotlib-inline==0.1.3 missingno==0.5.0 mistune==0.8.4 more-itertools==4.2.0 multimethod==1.6 mypy-extensions==0.4.3 nbclient==0.5.9 nbconvert==6.4.0 nbformat==5.1.3 nest-asyncio==1.5.4 netifaces==0.10.9 networkx==2.6.3 nltk==3.6.7 notebook==6.4.6 numpy==1.22.0 oauthlib==3.1.0 packaging==21.3 pandas==1.3.5 pandas-profiling==3.1.0 pandocfilters==1.5.0 panel==0.12.6 param==1.12.0 parso==0.8.3 pathspec==0.9.0 patsy==0.5.2 pexpect==4.8.0 phik==0.12.0 pickleshare==0.7.5 Pillow==9.0.0 platformdirs==2.4.1 pop-transition==1.1.2 prometheus-client==0.12.0 prompt-toolkit==3.0.24 protobuf==3.12.4 ptyprocess==0.7.0 pycairo==1.16.2 pycparser==2.21 pyct==0.4.8 pycups==2.0.1 pydantic==1.9.0 pydbus==0.6.0 Pygments==2.11.1 PyGObject==3.40.1 PyJWT==1.7.1 pymacaroons==0.13.0 PyNaCl==1.4.0 pyparsing==3.0.6 pyRFC3339==1.1 pyrsistent==0.18.0 python-apt===2.2.1pop0-1628521831-21.10-5dbe6cf python-dateutil==2.8.2 python-debian===0.1.39ubuntu1 python-xlib==0.29 pytz==2021.1 pyviz-comms==2.1.0 PyWavelets==1.2.0 pyxdg==0.27 PyYAML==5.3.1 pyzmq==22.3.0 qtconsole==5.2.2 QtPy==2.0.0 regex==2021.11.10 repolib==1.5.2 repoman==1.4.0 requests==2.25.1 scikit-learn==1.0.2 scipy==1.7.3 screen-resolution-extra==0.0.0 seaborn==0.11.2 SecretStorage==3.3.1 Send2Trash==1.8.0 sessioninstaller==0.0.0 simplejson==3.17.2 six==1.16.0 statsmodels==0.13.1 sweetviz==2.1.3 systemd-python==234 tangled-up-in-unicode==0.1.0 terminado==0.12.1 testpath==0.5.0 textblob==0.17.1 threadpoolctl==3.0.0 tomli==1.2.3 tornado==6.1 tqdm==4.62.3 traitlets==5.1.1 typing-extensions==4.0.1 ubuntu-advantage-tools==27.4 ubuntu-drivers-common==0.0.0 ufw==0.36.1 urllib3==1.26.5 visions==0.7.4 wadllib==1.3.5 wcwidth==0.2.5 webencodings==0.5.1 widgetsnbextension==3.5.2 wordcloud==1.8.1 xdg==5 xgboost==1.5.1 xkit==0.0.0 xlrd==2.0.1 zipp==3.7.0 ```

heming611 commented 2 years ago

ran into the same problem with pandas-profiling 3.1.0, downgraded it to 2.10.0 and the problem disappeared.

ghost commented 2 years ago

Also ran into it with pandas_profiling 3.1.0.
Solved by importing matplotlib after pandas_profiling and adding the magic command. Magic command is required otherwise nothing is displayed:

import pandas_profiling

import matplotlib.pyplot as plt
%matplotlib inline

plt.plot([1,2,3]);
fabclmnt commented 2 years ago

Same as #837