Mac: Selenium Error, Permission Error and selenium.common.exceptions.WebDriverException - python

The error is
/Users/erwinmac1/PycharmProjects/MachineLearning/venv/bin/python /Users/erwinmac1/PycharmProjects/MachineLearning/main.py
Traceback (most recent call last):
File "/Users/erwinmac1/PycharmProjects/MachineLearning/venv/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/Users/erwinmac1/Desktop/Chrome zip'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/erwinmac1/PycharmProjects/MachineLearning/main.py", line 6, in <module>
driver = webdriver.Chrome(PATH)
File "/Users/erwinmac1/PycharmProjects/MachineLearning/venv/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/Users/erwinmac1/PycharmProjects/MachineLearning/venv/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 86, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'Chrome zip' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
While my code is
from selenium import webdriver
PATH = "/Users/erwinmac1/Desktop/Chrome zip"
driver = webdriver.Chrome(PATH)
driver.get("https://www.youtube.com")
I don't know why this shows an error I've re-installed it a couple of times and it still shows this error any helps??

Your path is invalid (PATH = "/Users/erwinmac1/Desktop/Chrome zip")
go to your desktop and edit name of chromedriver as chromedriver and refresh project and rerun

Related

How can I run chromedriver on repl.it

I basically want to use selenium on repl.it, but don't know how to do that. I tried installing chromedriver into repl.it but I still get this error:
Traceback (most recent call last):
File "/home/runner/dictionaryBot/venv/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 71, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/subprocess.py", line 1704, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 3, in <module>
driver = webdriver.Chrome()
File "/home/runner/dictionaryBot/venv/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/runner/dictionaryBot/venv/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 90, in __init__
self.service.start()
File "/home/runner/dictionaryBot/venv/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
This is my code
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://youtube.com")
Try forking this Repl, it has working Selenium that you can use: Advanced Selenium Options

Issue with selenium chrome driver saying I have the wrong permission

This is my code
def driver():
length_of_string = 5
random_string = "".join(random.choice(string.ascii_letters) for i in range(length_of_string))
driver = webdriver.Chrome() # Ex. Mine is "C:\Users\Tevin\Downloads\chromedriver"
For some reason, calling the driver doesn't work. I've tried everything.
I put in the executable path directly and that also had the same error.
I installed the correct version of chromedriver
I also have the chromedriver in my env variables
This is the error I get
warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Traceback (most recent call last):
File "/home/vincentqchen/.local/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 74, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "cbbot.py", line 29, in <module>
driver()
File "cbbot.py", line 9, in driver
driver = webdriver.Chrome() # Ex. Mine is "C:\Users\Tevin\Downloads\chromedriver"
File "/home/vincentqchen/.local/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/vincentqchen/.local/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 90, in __init__
self.service.start()
File "/home/vincentqchen/.local/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 89, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable may have wrong permissions. Please see https://chromedriver.chromium.org/home```

Cannot running the file in selenium

I jut got installed and learnd about automation. And then when I wanna run this code:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.google.com")
there's an error like this line :
$ C:/Users/HELLO/AppData/Local/Programs/Python/Python39/python.exe d:/Lain-lain/belajarSele.py
Traceback (most recent call last):
File "C:\Users\HELLO\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\HELLO\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\HELLO\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\Lain-lain\belajarSele.py", line 3, in <module>
driver = webdriver.Chrome()
File "C:\Users\HELLO\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\HELLO\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
What should I do?
You need to download chromedriver from here
and once downloaded, you should define in your code like this :
driver = webdriver.Chrome("C:/Users/*****/Downloads/chromedriver_win32/chromedriver.exe")

Python Selenium Traceback (most recent call last):

I'm trying to use selenium for a python web scraper but when I try to run the program I get the following error:
"/Applications/Python 3.8/IDLE.app/Contents/MacOS/Python" "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 52548 --file /Users/xxxx/git/python/python_crawler_example_01/naver_crawling.py
pydev debugger: process 3004 is connecting
Connected to pydev debugger (build 192.7142.56)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Process finished with exit code 1
It's my error code:
from selenium import webdriver
from bs4 import BeautifulSoup as bs
import time
import os, sys
driver = webdriver.Chrome()
time.sleep(2)
driver.close()
I'm using macos & pycharm
https://i.stack.imgur.com/dJtFi.jpg
you should put the path of your webdriver
example:(if it is in the same directory)
driver = webdriver.Chrome(executable_path = "/chromedriver.exe")

Error "Service.py"

I'm new in Python and Pycharm and have some problem understanding this message:
Traceback (most recent call last):
File "C:\Users\reyde\PycharmProjects\Liderws\venv\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 997, in _execute_child
startupinfo)
PermissionError: [WinError 5] Acceso denegado
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/reyde/PycharmProjects/Liderws/Lider_ws.py", line 48, in <module>
browser21 = webdriver.Chrome(executable_path=rutaChromeDriver)
File "C:\Users\reyde\PycharmProjects\Liderws\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
self.service.start()
File "C:\Users\reyde\PycharmProjects\Liderws\venv\lib\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: 'Liderws' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Process finished with exit code 1
The error does say the webdriver has the wrong permissions. Is the path to ChromeDriver correct? Try to make the path something like:
browser21 = webdriver.Chrome(executable_path=C:\Webdrivers\chromedriver.exe)
Or wherever you have chromedriver saved, but make sure the path is directly to the exe.
Try redownloading the newest ChromeDriver available and place it in the folder you want. Don't forget to add it to system PATH and not just user.

Categories

Resources