user1457821
user1457821

Reputation: 33

chromedriver for selenium PermissionError: [Errno 1] Operation not permitted Error on Mac OSx

I have following python code

import time
from selenium import webdriver

driver = webdriver.Chrome('/Users/xxxx/Downloads/chromedriver')  
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()

When I execute this python script I am getting exception :

Traceback (most recent call last):
  File "/var/folders/0m/p0pyygms6g9_bqlfb9bmg0w80000gn/T/PythonRunner/dummy.py", line 4, in <module>
    driver = webdriver.Chrome('/Users/xxxx/Downloads/chromedriver')  # Optional argument, if not specified will search path.
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
    self.service.start()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 74, in start
    stdout=self.log_file, stderr=self.log_file)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 1] Operation not permitted: '/Users/xxxx/Downloads/chromedriver'

I have tried change permission of the chromedrive Linux executable to 777 and reinstalling selenium but got same error

I need assistance in trouble shooting this issue. Please let me know.

Upvotes: 1

Views: 2042

Answers (2)

undetected Selenium
undetected Selenium

Reputation: 193338

The error says it all as follows :

driver = webdriver.Chrome('/Users/xxxx/Downloads/chromedriver')  # Optional argument, if not specified will search path.

You have to mention the absolute path of the chromedriver binary through Key-Value pair as follows :

from selenium import webdriver

driver = webdriver.Chrome(executable_path='/Users/xxxx/Downloads/chromedriver')  
driver.get('http://www.google.com');

Upvotes: 1

eden zhang
eden zhang

Reputation: 16

You can try to move webdriver to / usr / local / bin

import time
from selenium import webdriver

driver = webdriver.Chrome()  
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()

Upvotes: 0

Related Questions