Issue 1:
AttributeError: module 'sip' has no attribute 'setapi'

Error appears for this one line code import matplotlib.pyplot as plt

Actual outcome

Traceback (most recent call last):
File "e:\GoogleDriveBB\Program\bb_git_repo\test.py", line 5, in <module>
import matplotlib.pyplot as plt
File "C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\matplotlib\pyplot.py", line 2336, in <module>
switch_backend(rcParams["backend"])
File "C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\matplotlib\__init__.py", line 703, in __getitem__
plt.switch_backend(rcsetup._auto_backend_sentinel)
File "C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\matplotlib\pyplot.py", line 256, in switch_backend
switch_backend(candidate)
File "C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\matplotlib\pyplot.py", line 276, in switch_backend
class backend_mod(matplotlib.backend_bases._Backend):
File "C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\matplotlib\pyplot.py", line 277, in backend_mod
locals().update(vars(importlib.import_module(backend_name)))
File "C:\ProgramData\Anaconda3\envs\mne\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 11, in <module>
from .backend_qt5 import (
File "C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\matplotlib\backends\backend_qt5.py", line 16, in <module>
import matplotlib.backends.qt_editor.figureoptions as figureoptions
File "C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\matplotlib\backends\qt_editor\figureoptions.py", line 11, in <module>
from matplotlib.backends.qt_compat import QtGui
File "C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\matplotlib\backends\qt_compat.py", line 172, in <module>
_setup()
File "C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\matplotlib\backends\qt_compat.py", line 132, in _setup_pyqt4
_setup_pyqt4_internal(api=2)
File "C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\matplotlib\backends\qt_compat.py", line 115, in _setup_pyqt4_internal
sip.setapi(_sip_api, api)
AttributeError: module 'sip' has no attribute 'setapi'

Matplotlib version

Operating system: Windows 10

Matplotlib version (import matplotlib; print(matplotlib.__version__)): 3.3.4

Matplotlib backend (print(matplotlib.get_backend())): not readable, this also produces the same error as above

Python version: 3.8.6

Jupyter version (if applicable): 1.0.0

Other libraries:

# Name Version Build Channel
appdirs 1.4.4 pyh9f0ad1d_0 conda-forge
apptools 5.1.0 pyh44b312d_0 conda-forge
argon2-cffi 20.1.0 py38h294d835_2 conda-forge
async_generator 1.10 py_0 conda-forge
attrs 20.3.0 pyhd3deb0d_0 conda-forge
backcall 0.2.0 pyh9f0ad1d_0 conda-forge
backports 1.0 py_2 conda-forge
backports.functools_lru_cache 1.6.1 py_0 conda-forge
bleach 3.3.0 pyh44b312d_0 conda-forge
blosc 1.21.0 h0e60522_0 conda-forge
brotli 1.0.9 h0e60522_4 conda-forge
brotlipy 0.7.0 py38h294d835_1001 conda-forge
bzip2 1.0.8 h8ffe710_4 conda-forge
ca-certificates 2021.1.19 haa95532_0
cached-property 1.5.1 py_0 conda-forge
certifi 2020.12.5 py38haa95532_0
cffi 1.14.4 py38hd8c33c5_1 conda-forge
cftime 1.4.1 py38h347fdf6_0 conda-forge
chardet 4.0.0 py38haa244fe_1 conda-forge
charls 2.2.0 h39d44d4_0 conda-forge
cloudpickle 1.6.0 py_0 conda-forge
colorama 0.4.4 pyh9f0ad1d_0 conda-forge
configobj 5.0.6 py_0 conda-forge
cryptography 3.3.1 py38hd8c33c5_1 conda-forge
curl 7.71.1 h4b64cdc_8 conda-forge
cvxpy 1.1.7 py38haa244fe_1 conda-forge
cvxpy-base 1.1.7 py38h4c96930_1 conda-forge
cycler 0.10.0 py_2 conda-forge
cytoolz 0.11.0 py38h294d835_3 conda-forge
dask-core 2021.1.1 pyhd8ed1ab_0 conda-forge
decorator 4.4.2 py_0 conda-forge
defusedxml 0.6.0 py_0 conda-forge
dipy 1.3.0 py38hbc2243c_1 conda-forge
double-conversion 3.1.5 h6538335_2 conda-forge
ecos 2.0.7.post1 py38h347fdf6_4 conda-forge
eigen 3.3.9 h2d74725_1 conda-forge
entrypoints 0.3 pyhd8ed1ab_1003 conda-forge
envisage 4.9.2 pyh9f0ad1d_1 conda-forge
expat 2.2.10 h39d44d4_0 conda-forge
ffmpeg 4.3.1 ha925a31_0 conda-forge
freetype 2.10.4 h546665d_1 conda-forge
giflib 5.2.1 h8d14728_2 conda-forge
gl2ps 1.4.2 h0597ee9_0 conda-forge
glew 2.1.0 h39d44d4_2 conda-forge
h5py 3.1.0 nompi_py38h022eade_100 conda-forge
hdf4 4.2.13 h0e5069d_1004 conda-forge
hdf5 1.10.6 nompi_h5268f04_1114 conda-forge
icu 68.1 h0e60522_0 conda-forge
idna 2.10 pyh9f0ad1d_0 conda-forge
imagecodecs 2021.1.11 py38h1ceb79b_1 conda-forge
imageio 2.9.0 py_0 conda-forge
imageio-ffmpeg 0.4.3 pyhd8ed1ab_0 conda-forge
importlib-metadata 3.4.0 py38haa244fe_0 conda-forge
importlib_metadata 3.4.0 hd8ed1ab_0 conda-forge
intel-openmp 2020.3 h57928b3_311 conda-forge
ipykernel 5.3.4 py38h5ca1d4c_0
ipython 7.20.0 py38hc5df569_1 conda-forge
ipython_genutils 0.2.0 py_1 conda-forge
ipywidgets 7.6.3 pyhd3deb0d_0 conda-forge
jedi 0.18.0 py38haa244fe_2 conda-forge
jinja2 2.11.3 pyh44b312d_0 conda-forge
joblib 1.0.0 pyhd8ed1ab_0 conda-forge
jpeg 9d h8ffe710_0 conda-forge
jsoncpp 1.9.4 h2d74725_1 conda-forge
jsonschema 3.2.0 py_2 conda-forge
jupyter 1.0.0 py38haa244fe_6 conda-forge
jupyter_client 6.1.11 pyhd8ed1ab_1 conda-forge
jupyter_console 6.2.0 py_0 conda-forge
jupyter_core 4.7.1 py38haa244fe_0 conda-forge
jupyterlab_pygments 0.1.2 pyh9f0ad1d_0 conda-forge
jupyterlab_widgets 1.0.0 pyhd8ed1ab_1 conda-forge
jxrlib 1.1 h8ffe710_2 conda-forge
kiwisolver 1.3.1 py38hbd9d945_1 conda-forge
krb5 1.17.2 hbae68bd_0 conda-forge
lcms2 2.11 h6a326e1_1 conda-forge
lerc 2.2.1 h0e60522_0 conda-forge
libaec 1.0.4 h39d44d4_1 conda-forge
libblas 3.9.0 7_mkl conda-forge
libcblas 3.9.0 7_mkl conda-forge
libclang 11.0.1 default_h5c34c98_1 conda-forge
libcurl 7.71.1 h4b64cdc_8 conda-forge
libdeflate 1.7 h8ffe710_5 conda-forge
libflang 5.0.0 h6538335_20180525 conda-forge
libiconv 1.16 he774522_0 conda-forge
liblapack 3.9.0 7_mkl conda-forge
libnetcdf 4.7.4 nompi_h3a9aa94_107 conda-forge
libogg 1.3.4 h8ffe710_1 conda-forge
libpng 1.6.37 h1d00b33_2 conda-forge
libsodium 1.0.18 h8d14728_1 conda-forge
libssh2 1.9.0 hb06d900_5 conda-forge
libtheora 1.1.1 h62dcd97_1004 conda-forge
libtiff 4.2.0 hc10be44_0 conda-forge
libwebp-base 1.2.0 h8ffe710_0 conda-forge
libxml2 2.9.10 hf5bbc77_3 conda-forge
libzopfli 1.0.3 h0e60522_0 conda-forge
llvm-meta 5.0.0 0 conda-forge
llvmlite 0.35.0 py38h57a6900_1 conda-forge
loguru 0.5.3 py38h32f6830_2 conda-forge
lz4-c 1.9.3 h8ffe710_0 conda-forge
m2w64-gcc-libgfortran 5.3.0 6 conda-forge
m2w64-gcc-libs 5.3.0 7 conda-forge
m2w64-gcc-libs-core 5.3.0 7 conda-forge
m2w64-gmp 6.1.0 2 conda-forge
m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge
markupsafe 1.1.1 py38h294d835_3 conda-forge
matplotlib 3.3.4 py38haa244fe_0 conda-forge
matplotlib-base 3.3.4 py38h34ddff4_0 conda-forge
mayavi 4.7.2 py38h8d3ad35_4 conda-forge
meshio 4.3.8 pyhd8ed1ab_0 conda-forge
mffpy 0.6.0 pyhd8ed1ab_0 conda-forge
mistune 0.8.4 py38h294d835_1003 conda-forge
mkl 2020.4 hb70f87d_311 conda-forge
mne 0.22.0 pyhd8ed1ab_2 conda-forge
mock 4.0.3 py38haa244fe_1 conda-forge
msys2-conda-epoch 20160418 1 conda-forge
nbclient 0.5.1 py_0 conda-forge
nbconvert 6.0.7 py38haa244fe_3 conda-forge
nbformat 5.1.2 pyhd8ed1ab_1 conda-forge
nest-asyncio 1.4.3 pyhd8ed1ab_0 conda-forge
netcdf4 1.5.5.1 nompi_py38h5338a22_101 conda-forge
networkx 2.5 py_0 conda-forge
nibabel 3.2.1 pyhd8ed1ab_0 conda-forge
nilearn 0.7.0 pyhd8ed1ab_0 conda-forge
notebook 6.2.0 py38haa244fe_0 conda-forge
numba 0.52.0 py38h4c96930_0 conda-forge
numexpr 2.7.2 py38h4c96930_0 conda-forge
numpy 1.20.0 py38h0cc643e_0 conda-forge
olefile 0.46 pyh9f0ad1d_1 conda-forge
openjpeg 2.4.0 h48faf41_0 conda-forge
openmp 5.0.0 vc14_1 conda-forge
openssl 1.1.1i h2bbff1b_0
osqp 0.6.2 py38h4c96930_1 conda-forge
packaging 20.8 pyhd3deb0d_0 conda-forge
pandas 1.2.1 py38h4c96930_0 conda-forge
pandoc 2.11.4 h8ffe710_0 conda-forge
pandocfilters 1.4.2 py_1 conda-forge
parso 0.8.1 pyhd8ed1ab_0 conda-forge
patsy 0.5.1 py_0 conda-forge
pickleshare 0.7.5 py_1003 conda-forge
pillow 8.1.0 py38hf7ce48b_1 conda-forge
pip 21.0.1 pyhd8ed1ab_0 conda-forge
pooch 1.3.0 pyhd8ed1ab_0 conda-forge
proj 7.2.0 h3e70539_1 conda-forge
prometheus_client 0.9.0 pyhd3deb0d_0 conda-forge
prompt-toolkit 3.0.14 pyha770c72_0 conda-forge
prompt_toolkit 3.0.14 hd8ed1ab_0 conda-forge
psutil 5.8.0 py38h294d835_1 conda-forge
pugixml 1.11.4 h0e60522_0 conda-forge
pycparser 2.20 pyh9f0ad1d_2 conda-forge
pydicom 2.1.2 pyhd3deb0d_0 conda-forge
pyedflib 0.1.20 pypi_0 pypi
pyface 7.1.0 pyh9f0ad1d_0 conda-forge
pygments 2.7.4 pyhd8ed1ab_0 conda-forge
pyopenssl 20.0.1 pyhd8ed1ab_0 conda-forge
pyparsing 2.4.7 pyh9f0ad1d_0 conda-forge
pyqt 5.12.3 py38haa244fe_7 conda-forge
pyqt-impl 5.12.3 py38h885f38d_7 conda-forge
pyqt5-sip 4.19.18 py38h885f38d_7 conda-forge
pyqtchart 5.12 py38h885f38d_7 conda-forge
pyqtwebengine 5.12.1 py38h885f38d_7 conda-forge
pyreadline 2.1 py38haa244fe_1003 conda-forge
pyrsistent 0.17.3 py38h294d835_2 conda-forge
pysocks 1.7.1 py38haa244fe_3 conda-forge
pysurfer 0.11.0 py_0 conda-forge
pytables 3.6.1 py38h153c448_3 conda-forge
python 3.8.6 h7840368_5_cpython conda-forge
python-dateutil 2.8.1 py_0 conda-forge
python-picard 0.4 pyh5ca1d4c_1 conda-forge
python_abi 3.8 1_cp38 conda-forge
pytz 2021.1 pyhd8ed1ab_0 conda-forge
pyvista 0.27.4 pyhd8ed1ab_0 conda-forge
pyvistaqt 0.3.0 pyhd8ed1ab_0 conda-forge
pywavelets 1.1.1 py38h347fdf6_3 conda-forge
pywin32 300 py38h294d835_0 conda-forge
pywinpty 0.5.7 py38h32f6830_1 conda-forge
pyyaml 5.4.1 py38h294d835_0 conda-forge
pyzmq 22.0.1 py38h7a0e47e_0 conda-forge
qdldl-python 0.1.5 py38h4c96930_0 conda-forge
qt 5.12.9 h5909a2a_3 conda-forge
qtconsole 5.0.2 pyhd8ed1ab_0 conda-forge
qtpy 1.9.0 py_0 conda-forge
requests 2.25.1 pyhd3deb0d_0 conda-forge
scikit-image 0.18.1 py38h4c96930_0 conda-forge
scikit-learn 0.24.1 py38ha09990b_0 conda-forge
scipy 1.5.2 pypi_0 pypi
scooby 0.5.6 pyh9f0ad1d_0 conda-forge
scs 2.1.2 py38h7465cd0_2 conda-forge
send2trash 1.5.0 py_0 conda-forge
setuptools 49.6.0 py38haa244fe_3 conda-forge
six 1.15.0 pyh9f0ad1d_0 conda-forge
snappy 1.1.8 ha925a31_3 conda-forge
spyder-kernels 1.10.1 py38haa244fe_1 conda-forge
sqlite 3.34.0 h8ffe710_0 conda-forge
statsmodels 0.12.2 py38h347fdf6_0 conda-forge
tbb 2020.2 h2d74725_3 conda-forge
tbb-devel 2020.2 h2d74725_3 conda-forge
terminado 0.9.2 py38haa244fe_0 conda-forge
testpath 0.4.4 py_0 conda-forge
threadpoolctl 2.1.0 pyh5ca1d4c_0 conda-forge
tifffile 2021.2.1 pyhd8ed1ab_0 conda-forge
tk 8.6.10 h8ffe710_1 conda-forge
toolz 0.11.1 py_0 conda-forge
tornado 6.1 py38h294d835_1 conda-forge
tqdm 4.56.0 pyhd8ed1ab_0 conda-forge
traitlets 5.0.5 py_0 conda-forge
traits 6.2.0 py38h294d835_0 conda-forge
traitsui 7.1.0 pyh9f0ad1d_0 conda-forge
urllib3 1.26.3 pyhd8ed1ab_0 conda-forge
utfcpp 3.1.2 0 conda-forge
vc 14.2 hb210afc_2 conda-forge
vs2015_runtime 14.28.29325 h5e1d092_0 conda-forge
vtk 9.0.1 no_osmesa_py38h3499093_104 conda-forge
wcwidth 0.2.5 pyh9f0ad1d_2 conda-forge
webencodings 0.5.1 py_1 conda-forge
wheel 0.36.2 pyhd3deb0d_0 conda-forge
widgetsnbextension 3.5.1 py38haa244fe_4 conda-forge
win32_setctime 1.0.3 py_0 conda-forge
win_inet_pton 1.1.0 py38haa244fe_2 conda-forge
wincertstore 0.2 py38haa244fe_1006 conda-forge
winpty 0.4.3 4 conda-forge
xlrd 2.0.1 pyhd8ed1ab_3 conda-forge
xz 5.2.5 h62dcd97_1 conda-forge
yaml 0.2.5 he774522_0 conda-forge
zeromq 4.3.3 h0e60522_3 conda-forge
zfp 0.5.5 h0e60522_4 conda-forge
zipp 3.4.0 py_0 conda-forge
zlib 1.2.11 h62dcd97_1010 conda-forge
zstd 1.4.8 h4e2f164_1 conda-forge

Issue 2:
Bug report

Bug summary

Playing around with getting information from the child artists in a legend, I ran into a strange issue where some operations disrupt the Jupyter Notebook inline figure display.

Code for reproduction

This seems to be a minimal example:

import matplotlib as mpl
import matplotlib.pyplot as plt

f, ax = plt.subplots()
leg = ax.legend([plt.Line2D([], [])], ["a line"], loc="lower left")
hpackers = leg.findobj(mpl.offsetbox.VPacker)[0].get_children()
for hpack in hpackers:
draw_area, text_area = hpack.get_children()
handles = draw_area.get_children()
assert any(artist.get_visible() for artist in handles)

Actual outcome

No error, but also no figure. If you then execute a different cell, the figure shows up there. If you execute the cell several times, the figures queue up, and then they're all displayed in the output are of the cell you execute.

Expected outcome

Normal behavior.

Matplotlib version

Operating system: MacOS

Matplotlib version: 3.3.0

Matplotlib backend (print(matplotlib.get_backend())): pylab inline

Python version: 3.8

Jupyter version (if applicable): IPython version 7.15.0