GCP环境下Ubuntu SSH启动Chrome远程桌面失败问题求助
问题排查:Chrome远程桌面启动失败(SyntaxError)
按照Screaming Frog官网步骤在Google Cloud Platform控制台部署环境,启动Chrome远程桌面时遇到以下问题:
执行命令
DISPLAY= /opt/google/chrome-remote-desktop/start-host --code="4/0AZEOvhVqPx3gYL01LCIWIK8idzut9v47hRYwL5QWi4EOhDt_JJaO0ZrPLMCs_EiMNacfCQ" --redirect-url="https://remotedesktop.google.com/_/oauthredirect" --name=$(hostname)
输入6位PIN码后出现错误:
[0725/094427.353260:ERROR:daemon_controller_delegate_linux.cc(99)] File "/opt/google/chrome-remote-desktop/chrome-remote-desktop", line 649 as infile, ^ SyntaxError: invalid syntax [0725/094427.353287:ERROR:daemon_controller_delegate_linux.cc(207)] Failed to start host. Couldn't start host.
服务状态检查
执行命令:
sudo systemctl status --no-pager chrome-remote-desktop@$USER
返回结果:
sudo systemctl status --no-pager chrome-remote-desktop@$USER ● chrome-remote-desktop@myname.service - Chrome Remote Desktop instance for myname Loaded: loaded (/lib/systemd/system/chrome-remote-desktop@.service; disabled; vendor preset: enabled) Active: inactive (dead)
排查与修复步骤
指定Python 3运行脚本
错误提示的语法问题是因为Chrome Remote Desktop脚本采用Python 3语法,但系统默认Python版本为2.x。修改启动命令,强制用Python 3执行:DISPLAY= python3 /opt/google/chrome-remote-desktop/start-host --code="你的授权码" --redirect-url="https://remotedesktop.google.com/_/oauthredirect" --name=$(hostname)永久修复脚本的Python版本指定
如果上述方法有效,可修改脚本头部的解释器指定:- 编辑脚本文件:
sudo nano /opt/google/chrome-remote-desktop/chrome-remote-desktop - 将第一行的
#!/usr/bin/env python改为#!/usr/bin/env python3 - 保存退出后重新执行启动命令
- 编辑脚本文件:
重新安装Chrome Remote Desktop
若脚本文件损坏,卸载后重新安装:sudo apt remove chrome-remote-desktop wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb sudo dpkg -i chrome-remote-desktop_current_amd64.deb sudo apt install -f验证Python 3依赖
确保系统已安装Python 3:sudo apt install python3 python3-pip
内容的提问来源于stack exchange,提问作者Shehzadi Aziz
相关产品推荐
相关产品推荐

