Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+3 in the same process is not support

  • 报错:
    • 形式1:
    • 形式2:
    • 原因
    • 报错的一般复现
    • 解决方案
    • 参考文献

程序员遇到这种环境问题的时候前列腺都不好, 记录一下, 方便以后回查~


报错:

报错有两种形式

形式1:

Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+3 in the same process is not support

形式2:

Gtk-Message: 18:20:57.303: Failed to load module "canberra-gtk-module"

原因

一般原因:
python 里 matplotlib 的 gtk使用版本(TK3AGG)与系统后端默认(一般是TKAGG)的gtk版本不一样,有时候就算你没用上import matplotlib包,opencv或者别的什么包也用到了, 一样报错, 其直接结果就是imshow没有图片。

本人原因:
我的情况是我写的rospy节点里面用到了opencv-python, ros节点在后面运行的时候, 其它用c++写的节点在使用cv::imshow()的时候运行报错程序而且程序还不崩只是没有图片。

报错的一般复现

下面脚本可以简单检查自己是否有这种版本冲突的问题:

import cv2
import matplotlib.plot as plt
cv2.namedWindow("test")

解决方案

这里我使用这个方案, 因为别的像 重新编译opencv, 太头大了:
命令行输入:

quit()

会显示一个文件:

/etc/matplotlibrc

接着命令行输入,

sudo gedit /etc/matplotlibrc

会出现这么个文件

### MATPLOTLIBRC FORMAT# This is a sample matplotlib configuration file - you can find a copy
# of it on your system in
# site-packages/matplotlib/mpl-data/matplotlibrc.  If you edit it
# there, please note that it will be overwritten in your next install.
# If you want to keep a permanent local copy that will not be
# overwritten, place it in the following location:
# unix/linux:
#     $HOME/.config/matplotlib/matplotlibrc or
#     $XDG_CONFIG_HOME/matplotlib/matplotlibrc (if $XDG_CONFIG_HOME is set)
# other platforms:
#     $HOME/.matplotlib/matplotlibrc
#
# See http://matplotlib.org/users/customizing.html#the-matplotlibrc-file for
# more details on the paths which are checked for the configuration file.
#
# This file is best viewed in a editor which supports python mode
# syntax highlighting. Blank lines, or lines starting with a comment
# symbol, are ignored, as are trailing comments.  Other lines must
# have the format
#    key : val # optional comment
#
# Colors: for the color values below, you can either use - a
# matplotlib color string, such as r, k, or b - an rgb tuple, such as
# (1.0, 0.5, 0.0) - a hex string, such as ff00ff - a scalar
# grayscale intensity such as 0.75 - a legal html color name, e.g., red,
# blue, darkslategrayGTKAgg GTKCairo GTK3Agg GTK3Cairo
# MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG#### CONFIGURATION BEGINS HERE# The default backend; one of GTK GTKAgg GTKCairo GTK3Agg GTK3Cairo
# MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG
# Template.
# You can also deploy your own backend outside of matplotlib by
# referring to the module name (which must be in the PYTHONPATH) as
# 'module://my_backend'.
#
# If you omit this parameter, it will always default to "Agg", which is a
# non-interactive backend.
backend      : GTKAgg# If you are using the Qt4Agg backend, you can choose here
# to use the PyQt4 bindings or the newer PySide bindings to
# the underlying Qt4 toolkit.
#backend.qt4 : PyQt4        # PyQt4 | PySide# Note that this can be overridden by the environment variable
# QT_API used by Enthought Tool Suite (ETS); valid values are
# "pyqt" and "pyside".  The "pyqt" setting has the side effect of
# forcing the use of Version 2 API for QString and QVariant.# The port to use for the web server in the WebAgg backend.
# webagg.port : 8888

把 GTKAgg改成GTKAgg GTKCairo GTK3Agg GTK3Cairo MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG中的一个, 这个GTKAgg应该是gtk+2.0, 可以改成GTK3Agg, 由于在jetson板子上问题的原因可能多种多样这里建议使用QT5Agg。因为python2 pip 好像已经不支持QT4了, 所以还没安装的话只能下载QT5。

x86架构下

pip install PyQt5

Arm架构下(jetson)

sudo apt-get install qt5-doc qt5-doc-html qtbase5-doc-html qtbase5-examples -y

保存以后问题的复现就没有了。

另外多提一句:
如果是在x86架构下(就是我们正常的电脑)其实可以降opencv-python的版本

pip install opencv-python==3.4.0

或许可行, 但是我仔细想想可能不够稳。

另外:

千万别神经刀删除GTK 比如 sudo apt-get purge gtk2.0-dev && sudo apt-get autoremove 那你的环境基本凉了, 因为你见到的很多基础的视觉库都是基于GTK这个基础的可视化包依赖来开发的,系统会删除使用GTK为依赖的所有库。

参考文献

非常非常感谢这几个链接
https://github.com/opencv/opencv/issues/6680
https://github.com/yosinski/deep-visualization-toolbox/issues/10
https://www.cnblogs.com/longwhite/p/10397754.html

正是同行的分享才可以让很多问题变得方便。

祝, 武运昌隆~

Gtk-ERROR : GTK+ 2.x symbols detected. Using GTK+2.x and GTK+3 in the same process is not support相关推荐

  1. OpenCV ERROE **: 02:07:27.741:GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the ...

    OpenCV ERROE **: 02:07:27.741:GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same proce ...

  2. error C4335: Mac file format detected: please convert the source file to either DOS or UNIX format

    vc里面遇到这个问题的解决方案 error C4335: Mac file format detected: please convert the source file to either DOS ...

  3. error: missing or invalid dependency detected while loading class file 'RDD.class'.

    问题重现如下: error: missing or invalid dependency detected while loading class file 'RDD.class'. Could no ...

  4. Maven : error: missing or invalid dependency detected while loading class file 'RDD.class'

    1.背景 报错 lcc@lcc spark-streaming-rocketmq$ mvn clean -X install -DskipTests=true[ERROR] error: missin ...

  5. Parsing error: No Babel config file detected for

    Parsing error: No Babel config file detected for的相关错误 上述不行就下面这个,一般上面图片的可以

  6. Parsing error: No Babel config file detected for xxx Either disable config file checking...报错解决方法

    Parsing error: No Babel config file detected for xxx Either disable config file checking-报错解决方法 使用Vu ...

  7. ubuntu运行MC-GPU程序报错error, no cuda enabled GPU detected by thread #0!!

    dell工作站安装了两个nvidia quadro k4000显卡,系统是ubuntu 11.10 安装了cuda 5.0. 由于MC-GPU程序运行不出结果,以为其中一个未连接显示器的显卡坏了. 我 ...

  8. Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not suppor

    1 import matplotlib matplotlib.use('Agg') 在导入matplotlib时马上添加

  9. swagger error: Conflicting schemaIds: Duplicate schemaIds detected for types A and B

    使用Web API并使用swashbuckle生成swagger文档,我在两个不同的命名空间中定义了两个具有相同名称的不同类.当我在浏览器中打开swagger页面时,它说: 1 Conflicting ...

最新文章

  1. 高等数学·为什么f``(x)小于0:则f(x)在[a,b]上的图形是凹的。f``(x)大于0:则f(x)在[a,b]上的图形是凸的。
  2. 报错解决:alueError: When using data tensors as input to a model, you should specify the `steps_per_epoch
  3. 2011年 软件所信息安全国家重点实验室复试回忆
  4. 远程连接:hive 报错:Permission denied: user=anonymous, access=EXECUTE
  5. 贼好用的Java工具类库,GitHub星标10k+,你在用吗?
  6. Linux虚拟化KVM-Qemu分析(四)之CPU虚拟化(2)
  7. PHP网页截图-网页快照实现
  8. 粘性定位(HTML、CSS)
  9. JVM启动参数手册——JVM之八
  10. c 语言查询条件并列怎么用,关于C# if语句中并列条件的执行
  11. LeetCode1456——定长子串中元音的最大数目
  12. 计算机教学反思杂文,教学反思或随笔
  13. PIXIJS学习笔记
  14. 使用安全杀毒软件禁止单个程序联网的方法,超详细
  15. 服务器异常消息微信通知
  16. BackTrack3 安装记录
  17. Phpstorm好用插件
  18. 利用亚马逊AWS搭建个人服务器
  19. 二进制中正负数表示和判断
  20. 漏洞扫描器 XRAY

热门文章

  1. 在比特大陆SE5边缘计算盒上运行PaddleOCR轻量级预测模型
  2. 【codeforces】1063C Dwarves, Hats and Extrasensory Abilities【二分】
  3. [学习笔记] BearPi-HM Nano - 开发板介绍
  4. googleMap 谷歌地图
  5. OpenLayers:加载GeoServer发布的WMTS、TMS服务
  6. 转载——服务器误删文件的恢复过程
  7. 江苏省工程训练赛--物料搬运小车(附代码)
  8. 7 Python文件与数据格式化
  9. seata报错问题总结 Unable to commit against JDBC Connection
  10. .netframewor金山卫士推送微软8月补丁 IE所有版本存在高危漏洞