gpt4 book ai didi

python - 在 AWS EC2 linux 中运行 selenium webdriver

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:06:34 35 4
gpt4 key购买 nike

我在 Amazon Linux AMI 上安装了 selenium。我尝试使用 python 来激活它。错误出现。我不知道应该是什么意思。 chrome webdriver 能否在该环境下运行。

我的代码

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

错误

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 86, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home`

更新:有新的错误。

 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

最佳答案

错误状态...

'chromedriver' executable may have wrong permissions

...这意味着它无法执行。如果您在 EC2 实例中添加执行位,它应该可以工作

$ chmod +x /home/ec2-user/dlfjj/bin/chromedriver

关于python - 在 AWS EC2 linux 中运行 selenium webdriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45527624/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com