在awsec2linux中运行selenium webdriver

2024-10-01 11:34:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我在AmazonLinuxAMI上安装了selenium。我尝试使用python来激活它。 错误出现了。我不知道这是什么意思。ChromeWebDriver可以在那个环境下运行吗。在

我的代码

from selenium import webdriver
driver = webdriver.Chrome("/home/ec2-user/dlfjj/bin/chromedriver")

错误

^{pr2}$

更新: 出现新错误。在

 Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ec2-user/dlfjj/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
    self.service.start()
  File "/home/ec2-user/dlfjj/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 96, in start
    self.assert_process_still_running()
  File "/home/ec2-user/dlfjj/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /home/ec2-user/dlfjj/bin/chromedriver unexpectedly exited. Status code was: 127

Tags: inpyhomelibpackageslocalselenium错误
2条回答

您缺少chromedriver所需的库!在

使用解压缩的chromedriver运行以下命令:

ldd chromedriver 

如果缺少依赖项,请使用以下命令安装它们:

^{pr2}$

正如错误所说:

'chromedriver' executable may have wrong permissions

只需在EC2实例中添加执行位

^{pr2}$

相关问题 更多 >