Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python lxc容器中的硒;WebDriverException:消息:无效参数:can';无法终止已退出的进程_Python_Selenium_Firefox_Geckodriver_Lxc - Fatal编程技术网

Python lxc容器中的硒;WebDriverException:消息:无效参数:can';无法终止已退出的进程

Python lxc容器中的硒;WebDriverException:消息:无效参数:can';无法终止已退出的进程,python,selenium,firefox,geckodriver,lxc,Python,Selenium,Firefox,Geckodriver,Lxc,我试图在Ubuntu 18.04(amd64)LXC容器中使用Selenium。 Selenium版本3.14.1, firefox版本62.0.3, Python 2.7 我安装了geckodriver-v0.22.0-linux64.tar.gz 从进入/usr/local/bin(在我的路径中) 尝试导入驱动程序时,出现以下错误: >>> from selenium import webdriver >>> driver = webdriver.Fire

我试图在Ubuntu 18.04(amd64)LXC容器中使用Selenium。
Selenium版本3.14.1, firefox版本62.0.3, Python 2.7

我安装了geckodriver-v0.22.0-linux64.tar.gz 从进入/usr/local/bin(在我的路径中)

尝试导入驱动程序时,出现以下错误:

>>> from selenium import webdriver
>>> driver = webdriver.Firefox()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
    keep_alive=True)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 253, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 324, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process
来自selenium导入webdriver的
>
>>>driver=webdriver.Firefox()
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/usr/local/lib/python2.7/dist packages/selenium/webdriver/firefox/webdriver.py”,第174行,在__
使_保持活动状态=真)
文件“/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py”,第157行,在__
启动会话(功能、浏览器配置文件)
文件“/usr/local/lib/python2.7/dist packages/selenium/webdriver/remote/webdriver.py”,第253行,在启动会话中
响应=self.execute(Command.NEW_会话,参数)
文件“/usr/local/lib/python2.7/dist packages/selenium/webdriver/remote/webdriver.py”,执行中的第324行
self.error\u handler.check\u响应(响应)
文件“/usr/local/lib/python2.7/dist packages/selenium/webdriver/remote/errorhandler.py”,第242行,在check_响应中
引发异常类(消息、屏幕、堆栈跟踪)
selenium.common.exceptions.WebDriverException:消息:无效参数:无法终止已退出的进程
我看到了类似的帖子,问题最终变成了Selenium、Firefox和GeckoDriver之间的版本兼容性问题,但我不认为我是这样

我在谷歌上搜索了又搜索,没有运气。也看了几篇github帖子,仍然不走运。我希望这里有人能给我一些想法


在容器中执行此操作可能有问题。然而,我确实在一个普通的Ubuntu系统上(不是在一个容器中)尝试了这一点,并得到了完全相同的问题。

为了防止有人偶然发现这一点并遇到类似的问题,我的问题的根源是,我最初使用webdriver的所有尝试都发生在
lxc exec bash
,或者来自
ssh
会话,而不使用ssh x11转发。在这两种情况下,pythonwebdriver都失败了,因为它实际上无法启动浏览器。我现在已经在几个不同的环境中运行了它,所有这些都使用x11转发,并且运行正常

这可能是一个愚蠢的问题,但你是如何安装它的?你解压了tar.gz并给了二进制文件执行权限了吗?@SantiagoBruno我从网站上下载了它,解压后复制到我的路径上。它位于lxc容器中,因此所有内容都以root身份运行,并具有root权限,二进制文件对所有用户都具有执行权限。权限应该没问题。我刚刚在我坐着的Linux笔记本电脑上尝试了一个快速测试程序。我做了所有相同的步骤,效果很好。做了那个测试,我意识到它实际上启动了浏览器。我想知道这是否与在没有显示器的lxc中运行它有关。我运行此测试的服务器有相同的问题,可能是Ubuntu的服务器版本(缺少显示管理器),但我不是100%确定。您应该始终以非root用户的身份执行@Test。@DebanjanB如前所述,这是在容器中运行的。唯一的用户是root,因为我没有设置其他用户,因为没有理由这样做。在此上下文中,建议以非根用户身份运行是不相关的。