简体   繁体   中英

Running selenium webdriver in AWS EC2 linux

I installed selenium on Amazon Linux AMI. I try to use python to activate it. The error show up. I do not know what is supposed to mean. Can chrome webdriver run on that environment.

My code

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

Error

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` 

update: There is new error.

 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

The error states ...

'chromedriver' executable may have wrong permissions

... which means that it cannot be executed. It should work if you add the execute bit in the EC2 instance

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

You are missing a library needed by chromedriver!

Run the below command with an unzipped chromedriver :

ldd chromedriver 

If there are missing dependencies, then install them using the below command :

yum install GConf2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM