Selenium Python: 没有这样的文件或目录: '/usr/local/bin/chromedriver' 但它存在并被添加到路径

Selenium Python: No such file or directory: '/usr/local/bin/chromedriver' but it exists and is added to path

尝试在 Docker Apline Linux 上 运行 selenium python 并收到 "Message: 'chromedriver' executable needs to be in PATH" 错误,因为它认为该文件不存在。但是在其他答案中尝试了我能做的一切,但它仍然无法启动。

这是我到目前为止尝试过的:

看到错误。

更新: 在 Docker 文件中添加这些包。

RUN apk --update --no-cache add\
  alpine-sdk\
  autoconf\
  automake\
  bash\
  binutils-gold\
  build-base\
  curl\
  dumb-init\
  g++\
  gcc\
  gcompat\
  git\
  gnupg\
  gzip\
  jpeg\
  jpeg-dev\
  libc6-compat\
  libffi\
  libffi-dev\
  libpng\
  libpng-dev\
  libstdc++\
  libtool\
  linux-headers\
  make\
  mysql\
  mysql-client\
  mysql-dev\
  mesa-gles\
  nasm\
  nodejs\
  nss\
  openjdk8-jre\
  openssh-client\
  paxctl\
  python3\
  python3-dev\
  sudo\
  tar\
  unzip\
  wget\
  chromium

还有 shell 脚本,我正在使用

获取 Chromedriver
#!/bin/bash

LATEST_CHROMEDRIVER=$(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
curl -L https://chromedriver.storage.googleapis.com/$LATEST_CHROMEDRIVER/chromedriver_linux64.zip >> chromedriver.zip
mv -f chromedriver.zip /usr/local/bin/chromedriver.zip
unzip /usr/local/bin/chromedriver.zip -d /usr/local/bin
chmod a+x /usr/local/bin/chromedriver
sudo ln -s /usr/local/bin/chromedriver /usr/bin/chromedriver
rm /usr/local/bin/chromedriver.zip

ldd 的输出表明 chromedriver 是针对 glibc (GNU standard C library), which isn't compatible to vanilla Alpine, using musl libc 构建的。

要解决此问题,请尝试安装 Alpine 兼容版本的 chromedriver,可在 Alpine 存储库中使用 apk add chromium-chromedriver:

https://pkgs.alpinelinux.org/package/v3.9/community/x86_64/chromium-chromedriver