environment
aws ec2
ec2-user:~ $ which python
alias python='python36'
/usr/bin/python36
ec2-user:~ $ pip install chromedriver
Requirement already satisfied: chromedriver in ./.local/lib/python3.6/site-packages (2.24.1)
ec2-user:/usr/local/bin $ ls
chromedriver
question
How can I proceed chromeDriver.py and get a wanted result?
ec2-user:~/environment $ wget https://chromedriver.storage.googleapis.com/78.0.3904.70/chromedriver_linux64.zip
--2019-11-18 03:14:39-- https://chromedriver.storage.googleapis.com/78.0.3904.70/chromedriver_linux64.zip
Resolving chromedriver.storage.googleapis.com (chromedriver.storage.googleapis.com)... 172.217.25.112, 2404:6800:4004:80b::2010
Connecting to chromedriver.storage.googleapis.com (chromedriver.storage.googleapis.com)|172.217.25.112|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5527671 (5.3M) [application/zip]
Saving to: ‘chromedriver_linux64.zip’
chromedriver_linux64.zip 100%[=======================================>] 5.27M --.-KB/s in 0.1s
‘chromedriver_linux64.zip’ saved [5527671/5527671]
chromeDriver.py
from time import sleep
from selenium import webdriver
browser = webdriver.Chrome('/usr/local/bin/chromedriver')
browser.get("https://www.google.com")
browser.save_screenshot("screen.png")
sleep(5)
browser.close()
This is a result.
ec2-user:~/environment $ python3 chromeDriver.py
Traceback (most recent call last):
File "/home/ec2-user/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib64/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib64/python3.6/subprocess.py", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/usr/local/bin/chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "chromeDriver.py", line 4, in <module>
browser = webdriver.Chrome('/usr/local/bin/chromedriver')
File "/home/ec2-user/.local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/home/ec2-user/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 88, 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
Is it correct to read selenium from the path "$HOME:/.local/lib/python3.6/site-packages" ?