无法在亚马逊红帽服务器上安装 google-chrome

无法在亚马逊红帽服务器上安装 google-chrome

我正在尝试在亚马逊服务器上安装 google-chrome

NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"

依照指示https://access.redhat.com/discussions/917293

但它给了我如下的依赖错误并且没有安装

--> Processing Dependency: libgtk-3.so.0()(64bit) for package: google-chrome-stable-71.0.3578.98-1.x86_64
--> Finished Dependency Resolution
Error: Package: google-chrome-stable-71.0.3578.98-1.x86_64 (/google-chrome-stable_current_x86_64)
           Requires: libappindicator3.so.1()(64bit)
Error: Package: google-chrome-stable-71.0.3578.98-1.x86_64 (/google-chrome-stable_current_x86_64)
           Requires: libatspi.so.0()(64bit)
Error: Package: google-chrome-stable-71.0.3578.98-1.x86_64 (/google-chrome-stable_current_x86_64)
           Requires: xdg-utils
Error: Package: google-chrome-stable-71.0.3578.98-1.x86_64 (/google-chrome-stable_current_x86_64)
           Requires: libatk-bridge-2.0.so.0()(64bit)
Error: Package: google-chrome-stable-71.0.3578.98-1.x86_64 (/google-chrome-stable_current_x86_64)
           Requires: libatk-1.0.so.0()(64bit)
Error: Package: google-chrome-stable-71.0.3578.98-1.x86_64 (/google-chrome-stable_current_x86_64)
           Requires: liberation-fonts
Error: Package: google-chrome-stable-71.0.3578.98-1.x86_64 (/google-chrome-stable_current_x86_64)
           Requires: libgdk-3.so.0()(64bit)
Error: Package: google-chrome-stable-71.0.3578.98-1.x86_64 (/google-chrome-stable_current_x86_64)
           Requires: libgdk_pixbuf-2.0.so.0()(64bit)
Error: Package: google-chrome-stable-71.0.3578.98-1.x86_64 (/google-chrome-stable_current_x86_64)
           Requires: libXss.so.1()(64bit)
Error: Package: google-chrome-stable-71.0.3578.98-1.x86_64 (/google-chrome-stable_current_x86_64)
           Requires: libgtk-3.so.0()(64bit)
 You could try using --skip-broken to work around the problem

甚至尝试使用 --skip-broken 进行上述操作,但仍未安装,

yum list installed google-chrome
Loaded plugins: fastestmirror, priorities, update-motd, upgrade-helper
Loading mirror speeds from cached hostfile
 * amzn-main: packages.us-east-1.amazonaws.com
 * amzn-updates: packages.us-east-1.amazonaws.com
Error: No matching Packages to list

尝试解决依赖关系,但奇怪的是亚马逊 yum 存储库中没有软件包

 yum search libappindicator3
Loaded plugins: fastestmirror, priorities, update-motd, upgrade-helper
Loading mirror speeds from cached hostfile
 * amzn-main: packages.us-east-1.amazonaws.com
 * amzn-updates: packages.us-east-1.amazonaws.com
Warning: No matches found for: libappindicator3
No matches found

然后跟着这个 https://stackoverflow.com/questions/22836219/centos-6-5-howto-install-gtk-version-2-8-0

yum install gtk+-devel gtk2-devel
Loaded plugins: fastestmirror, priorities, update-motd, upgrade-helper
Loading mirror speeds from cached hostfile
 * amzn-main: packages.us-east-1.amazonaws.com
 * amzn-updates: packages.us-east-1.amazonaws.com
amzn-main                                                                                                                                                                                                              | 2.1 kB  00:00:00     
amzn-updates                                                                                                                                                                                                           | 2.5 kB  00:00:00     
No package gtk+-devel available.
No package gtk2-devel available.
Error: Nothing to do

然后我找到了 rpm 仓库,并尝试直接从那里安装,再次使用递归依赖项

https://centos.pkgs.org/7/centos-x86_64/gtk2-devel-2.24.31-1.el7.x86_64.rpm.html

rpm -ivh http://mirror.centos.org/centos/7/os/x86_64/Packages/gtk2-devel-2.24.31-1.el7.x86_64.rpm
Retrieving http://mirror.centos.org/centos/7/os/x86_64/Packages/gtk2-devel-2.24.31-1.el7.x86_64.rpm
warning: /var/tmp/rpm-tmp.qvgrSF: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
    atk-devel >= 1.29.4-2 is needed by gtk2-devel-2.24.31-1.el7.x86_64
    cairo-devel >= 1.6.0-1 is needed by gtk2-devel-2.24.31-1.el7.x86_64
    gdk-pixbuf2-devel is needed by gtk2-devel-2.24.31-1.el7.x86_64
    glib2-devel >= 2.28.0-1 is needed by gtk2-devel-2.24.31-1.el7.x86_64
    gtk2 = 2.24.31-1.el7 is needed by gtk2-devel-2.24.31-1.el7.x86_64
    libXcomposite-devel is needed by gtk2-devel-2.24.31-1.el7.x86_64
    libXcursor-devel is needed by gtk2-devel-2.24.31-1.el7.x86_64
    libatk-1.0.so.0()(64bit) is needed by gtk2-devel-2.24.31-1.el7.x86_64
    libgailutil.so.18()(64bit) is needed by gtk2-devel-2.24.31-1.el7.x86_64
    libgdk-x11-2.0.so.0()(64bit) is needed by gtk2-devel-2.24.31-1.el7.x86_64
    libgdk_pixbuf-2.0.so.0()(64bit) is needed by gtk2-devel-2.24.31-1.el7.x86_64
    libgtk-x11-2.0.so.0()(64bit) is needed by gtk2-devel-2.24.31-1.el7.x86_64
    pango-devel >= 1.20.0-1 is needed by gtk2-devel-2.24.31-1.el7.x86_64
    pkgconfig(atk) is needed by gtk2-devel-2.24.31-1.el7.x86_64
    pkgconfig(cairo) is needed by gtk2-devel-2.24.31-1.el7.x86_64
    pkgconfig(gdk-pixbuf-2.0) is needed by gtk2-devel-2.24.31-1.el7.x86_64
    pkgconfig(gio-2.0) is needed by gtk2-devel-2.24.31-1.el7.x86_64
    pkgconfig(pango) is needed by gtk2-devel-2.24.31-1.el7.x86_64
    pkgconfig(pangocairo) is needed by gtk2-devel-2.24.31-1.el7.x86_64
    pkgconfig(pangoft2) is needed by gtk2-devel-2.24.31-1.el7.x86_64

我确实尝试解决所有丢失的软件包但它们不存在并且我无法安装 chrome。

答案1

我解决了这个问题,安装了最新的 chrome 版本,并让它在无头模式下工作,

使用非常有效的脚本https://intoli.com/blog/installing-google-chrome-on-centos/

最快的方法是运行命令:curl https://intoli.com/install-google-chrome.sh | bash

它安装了所有依赖项并安装了最新稳定版本的应用程序。

最终的目标是能够使用 selenium 运行它,并进行一些细微的调整以使其在无头模式下运行,并使其与 selenium 一起工作。

chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
browser = webdriver.Chrome('/path_to_chrome_driver',chrome_options=chrome_options)

运行顺利。

答案2

简单的回答是第一个链接的教程(access.redhat.com/...)不适用于 AMI。

Amazon AMI 有能力并且似乎已经采取了这种能力来限制其 AMI 中的存储库和软件包的可用性,可能会考虑与以下 AMI 合作:

https://aws.amazon.com/marketplace/pp/B00KWBZVK6/ref=ptnr_catgtm_centos

与您提到的不同,这个允许上游 repo 更新和添加。

相关内容