vnc和anaconda冲突解决

vnc桌面无法打开

更新:发现了更简单的方法

先退出conda环境

conda deactivate

再启动vnc即可


如果发现vnc桌面无法连接 查看服务监听端口没有查询结果

netstat -lnpt|grep Xvnc

或者只在开启vnc服务命令后几秒有结果

systemctl start vncserver@:1  #开启vnc服务

则说明vnc服务启动失败,这时候先查看所需端口是否开放,确认端口开放后,考虑是否与anaconda冲突

如果安装过anaconda,在启动vnc服务时,环境中anaconda bin目录中的dbus-daemon会与系统自带的dbus-daemon冲突。

解决方法是先注释掉bashrc中anacodna的相关部分

vim ~/.bashrc  #打开bashrc

bashrc中内容类似于

# .bashrc
  2 
  3 # User specific aliases and functions
  4 
  5 alias rm='rm -i'
  6 alias cp='cp -i'
  7 alias mv='mv -i'
  8 
  9 # Source global definitions
 10 if [ -f /etc/bashrc ]; then
 11     . /etc/bashrc
 12 fi
 13 
 14 umask 027
 15                                                                                                                                                                                        
 16 # >>> conda initialize >>>
 17 # !! Contents within this block are managed by 'conda init' !!
 18 __conda_setup="$('/root/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
 19 if [ $? -eq 0 ]; then
 20     eval "$__conda_setup"
 21 else
 22     if [ -f "/root/anaconda3/etc/profile.d/conda.sh" ]; then
 23         . "/root/anaconda3/etc/profile.d/conda.sh"
 24     else
 25         export PATH="/root/anaconda3/bin:$PATH"
 26     fi
 27 fi
 28 unset __conda_setup
 29 # <<< conda initialize  <<<

将condainitialize到这部分整体注释掉

# .bashrc
  2 
  3 # User specific aliases and functions
  4 
  5 alias rm='rm -i'
  6 alias cp='cp -i'
  7 alias mv='mv -i'
  8 
  9 # Source global definitions
 10 if [ -f /etc/bashrc ]; then
 11     . /etc/bashrc
 12 fi
 13 
 14 umask 027
 15                                                                                                          16 <<COMMENT                                                                           
 17 # >>> conda initialize >>>
 18 # !! Contents within this block are managed by 'conda init' !!
 19 __conda_setup="$('/root/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
 20 if [ $? -eq 0 ]; then
 21     eval "$__conda_setup"
 22 else
 23     if [ -f "/root/anaconda3/etc/profile.d/conda.sh" ]; then
 24         . "/root/anaconda3/etc/profile.d/conda.sh"
 25     else
 26         export PATH="/root/anaconda3/bin:$PATH"
 27     fi
 28 fi
 29 unset __conda_setup
 30 # <<< conda initialize  <<<
 31 COMMENT

然后保存退出,并刷新bashrc

source ~/.bashrc  #刷新

然后需要重新打开一个命令行界面,并启动vnc

在vnc启动成功,确认远程可以连接后

将bashrc中的内容还原,并重新刷新

source ~/.bashrc  #刷新

目前还没有更好的解决方法


文章作者: keevinzha
版权声明: 咳咳想白嫖文章?本文章著作权归作者所有,任何形式的转载都请注明出处。 https://www.keevinzha.com !
  目录