opencvのGUIが起動できない

pythonopencvを使っていると以下のエラーでGUIが使えなかった。 適当にググるとcondaを使え、などと書いてある。condaは使いたくない。

error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvNamedWindow'

以下で解決。

# opencv-pythonやopencv-python-headlessとversionを揃える
pip3 install opencv-contrib-python==$(pip3 list 2>&1|grep opencv-python|head -n1|awk '{print $2}')