在EC2 Ubuntu服务器上运行Google Chrome无头浏览器。

8

你好,我有一个ec2服务器,以下是配置:

公共DNS(IPv4):ec2-18-191-6-130.us-east-2.compute.amazonaws.com

AMI ID:ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20200611 (ami-0a63f96e85105c6d3)

当我试图安装Google Chrome以便使用headless时,遇到了以下问题:

cat: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference

我按照以下简单教程在我的ec2服务器上安装Chrome: https://understandingdata.com/install-google-chrome-selenium-ec2-aws/
1个回答

24

我尝试复制并且遇到了和你一样的问题。但是,有一个可行的替代方法适用于我。你可以尝试该方法,最好在全新的Ubuntu实例上。

安装先决条件

sudo apt update
sudo apt install unzip libnss3 python3-pip

安装Chrome 83驱动程序

cd /tmp/
sudo wget https://chromedriver.storage.googleapis.com/83.0.4103.39/chromedriver_linux64.zip
sudo unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/bin/chromedriver
chromedriver --version

安装Google Chrome稳定版当前版本(83)

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb

检查安装

google-chrome-stable --version

安装selenium

pip3 install selenium --user

我的测试中安装成功,但我还没有验证selenium是否按预期工作。我只关注chromeselenium是否安装成功。


2
我尝试了你的方法,不幸的是它对我没有任何改变,我仍然遇到同样的错误。 - ahmedaao
2
@ahmedaao 你尝试在新的Ubuntu实例上运行了吗?之前,我只有在启动干净的实例后才能使其正常工作。 - Marcin
1
非常好的答案 - 非常感谢 - mmz
有什么运气吗?进展如何? - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接