【问题标题】:Invalid argument: can't kill an exited process, running Selenium in Python with geckodriver无效参数:无法终止已退出的进程,使用 geckodriver 在 Python 中运行 Selenium
【发布时间】:2020-09-10 09:57:54
【问题描述】:

操作系统:Ubuntu 18.04.3 LTS
Geckodriver 版本:0.26
火狐版本:76.0.1
Python 版本:3.6.9
硒版本:3.141.0

我的代码:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver_options = Options()
driver_options.headless = True
browser = webdriver.Firefox(options=driver_options)

... do stuff

首先,此设置在我的 Mac 上运行良好,当我将其发送到生产环境时,我收到了该错误。 这两天我一直在尝试解决这个问题。

我发现了两个可能导致此问题的主要因素:

1590245018121   mozrunner::runner   INFO    Running command: "/var/www/mycode/env/bin/firefox" "-marionette" "-headless" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile7raE8H"
/var/www/mycode/env/bin/firefox: 1: /var/www/mycode/env/bin/firefox: which: not found

【问题讨论】:

    标签: python selenium ubuntu gunicorn geckodriver


    【解决方案1】:

    由于我可以从终端运行脚本,我最终意识到问题出在 gunicorn。我不得不添加 Environment="PATH=/usr/bin" 到服务器上运行的 gunicorn 服务脚本。

    【讨论】:

      猜你喜欢
      • 2019-03-03
      • 2020-02-22
      • 2020-06-11
      相关资源
      最近更新 更多