1. 前言
创作开始时间:2021年9月29日13:00:23
本文记录一下由于安装matplotlib和seaborn直接导致vncviewer远程连接界面异常的场景。(困扰我一个上午)。之所以记录,是因为这个问题太坑了,我根本没想到是这个原因。
2. 环境
- 阿里云服务器 Ubuntu 16.04 操作系统
- vncviewer界面
- vscode
- conda环境(运行python脚本画图)
3. 问题描述
今天想在服务器里面用seaborn和matplotlib作图,然后发现系统报错:
QXcbConnection: Failed to initialize XRandr
Qt: XKEYBOARD extension not present on the X server
所以,seaborn在这里面作不了图??
我想解决这个问题,所以我就去网上找参考:
- Qt: XKEYBOARD extension not present on the X server.的解决方法 https://blog.csdn.net/piaopiaopiaopiaopiao/article/details/98071216 (说要配置环境变量,么得用)
- ubuntu下spyder无法进行键盘输入—Qt: XKEYBOARD extension not present on the X server. https://blog.csdn.net/capecape/article/details/80000383 (同样不起作用)
- How do I configure a vnc server which supports xkeyboard extention? [https://askubuntu.com/questions/880946/how-do-i-configure-a-vnc-server-which-supports-xkeyboard-extention 运行
xdpyinfo -ext XKEYBOARD | tail](https://askubuntu.com/questions/880946/how-do-i-configure-a-vnc-server-which-supports-xkeyboard-extention 运行
xdpyinfo -ext XKEYBOARD | tail) -2`,也没用
我手贱运行了xdpyinfo -ext XKEYBOARD | tail -2
,然后restart了vnc。结果发现界面异常了!震惊
我正常界面是这样的:
异常界面:上图红框中的东西(也就是上下菜单栏)都没了,而且nautilus(终端)也打不开了。
为此,接下来,我研究了几个小时。。。具体过程如下
1)先是做无用功,
2)然后通过自己的思考和尝试,终于找到了原因
4. 失败尝试(无用功)
虽然是“无用功”,但是也是自己一个探索的过程。代表了我的思维流向,所以还是记录下:
- 反复修改xstartup
- 反复copy出~/.vnc文件夹下面的vnc log中的error message到搜索引擎,寻找解决方案
- 换一个conda env,重新安装matplotlib和seaborn
- 重装nautilus
- 杀掉vnc,dbus进程
- 设置、运行dbus-launch 之类的指令
- 重启电脑(没有办法中的办法,终极方案)。
都没有用。
大概参考的网页可能有二三十个,有些页面被我关了,大概就参考以下网页:
- 下载xmanager https://www.netsarang.com/zh/thank-you-download/ 没用,而且没有免费版
- Qt not loading on Remote Desktop (failed to initialize XRandr) https://stackoverflow.com/questions/63359117/qt-not-loading-on-remote-desktop-failed-to-initialize-xrandr 没用
- VNC Viewer中启动qt5.5.0的qtcreator,报告QXcbConnection: Failed to initialize XRandr等,无法启动_lang999888的专栏-程序员宅基地 https://www.cxyzjd.com/article/lang999888/48850351 (不知所云,没用)
- QXcbConnection: Failed to initialize XRandr #25 https://github.com/YuvalNirkin/face_swap/issues/25 没用。
- vnc 登录 Ubuntu gnome 桌面出现 QXcbConnection : Failed to initialize XRandr 错误,然后打不开 https://www.cnblogs.com/chenfulin5/p/8607409.html 没用
- Part of the keyboard is not functional when working with vncserver without XKEYBOARD support https://bugreports.qt.io/browse/QTBUG-44938
- ubuntu下spyder无法进行键盘输入—Qt: XKEYBOARD extension not present on the X server. https://www.daimajiaoliu.com/daima/4794f9e54100404
- RStudio QT xkeyboard issue in a Ubuntu VNC https://community.rstudio.com/t/rstudio-qt-xkeyboard-issue-in-a-ubuntu-vnc/10167
- No keyboard responding for Spyder when started through VNC #3713 https://github.com/spyder-ide/spyder/issues/3713
- VncViewer, why certain keys stop working? https://www.unix.com/unix-for-dummies-questions-and-answers/244852-vncviewer-why-certain-keys-stop-working.html
- XKeyboard extension not present! https://www.raspberrypi.org/forums/viewtopic.php?t=152717
- ROS via VNC “XKEYBOARD extension not present” https://answers.ros.org/question/350143/ros-via-vnc-xkeyboard-extension-not-present/
- Issues with dbus-launch and x11 forwarding and /etc/machine-id? #2016 https://github.com/Microsoft/WSL/issues/2016
- X11 Dependency, Compile Dbus without X11, starting only Shell C++ Applications Raspbian Linux https://stackoverflow.com/questions/22346424/x11-dependency-compile-dbus-without-x11-starting-only-shell-c-applications-r
- DBus session bus address is not properly set https://bbs.archlinux.org/viewtopic.php?id=221340
- d-bus administration https://stackoverflow.com/questions/7104111/d-bus-administration
- what to use instead of dbus-launch https://bbs.archlinux.org/viewtopic.php?id=229626
- Problem with “gnome-terminal” on Gnome 3.12.2 askubuntu.com/questions/608330/problem-with-gnome-terminal-on-gnome-3-12-2
- gnome-terminal fails to start (timed out) https://askubuntu.com/questions/1108808/gnome-terminal-fails-to-start-timed-out/1128108#1128108
5. 成功尝试(通过自己的理解)
挣扎了这么几个小时,该看的网页都看了,该静下心来思考一下了:
我想来想去,我也没做什么操作,除了:
1)安装seaborn和matplotlib
2)手贱运行了下xdpyinfo -ext XKEYBOARD | tail -2
安装xmanager之后,再运行了一遍xdpyinfo -ext XKEYBOARD | tail -2
,发现这个并不会修改系统设置,那么2)已经可以被排除了,只有1)(可能)会修改系统配置。
脑袋灵光乍现,果断卸载seaborn和matplotlib,此时再次重启,重启成功后发现界面恢复正常!
泪目了
6. 思考人生
- 现在网上重复的博文太多了,感觉都在反复转载或者抄袭?难顶。
- 我解决问题的模式还是要继续变通变通。目前太笨了:直接找解决方案,找到一个就试一个,乱试。最后很难恢复啊!这样很容易破坏原本的环境。所以我觉得改进方法是:1)先明确要解决的问题;2)找到解决方案后,先弄明白这个方案的原理;3)记录方案下的每一步过程,方便后面反推或者还原。
7. 小结
以上。服务器没法画图了,只能在本地了。
创作结束时间:2021年9月29日13:38:46