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")
Related
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
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")
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
This question already has answers here:
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH error with Headless Chrome
(1 answer)
WebDriverException: Message: 'chromedriver' executable needs to be in PATH while setting UserAgent through Selenium Chromedriver python
(1 answer)
Closed 2 years ago.
I cant find the soluiton for this errors, the code is really simple but i can't fix it, please help
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get("www.google.com")
driver.close()
i tried with geckodriver, and with the path in all the ways, but there's no change
Traceback (most recent call last):
File "/home/lautaro/.local/lib/python3.8/site-
packages/selenium/webdriver/common/service.py", line 72, 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)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/lautaro/.local/lib/python3.8/site-
packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/home/lautaro/.local/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
This question already has answers here:
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH error with Headless Chrome
(1 answer)
WebDriverException: Message: 'chromedriver' executable needs to be in PATH while setting UserAgent through Selenium Chromedriver python
(1 answer)
Closed 2 years ago.
I can run the script for autotesting.
Here is the script
from selenium import webdriver
PATH = "Z:\PyProjects\venv\Scripts\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://google.com/")
And this is the error I am getting after running the script
Z:\PyProjects\venv\Scripts\python.exe Z:/PyProjects/test.py
Traceback (most recent call last):
File "Z:\PyProjects\venv\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Python38\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Python38\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] unable to find the file
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "Z:/PyProjects/test.py", line 3, in <module>
driver = webdriver.Chrome(PATH)
File "Z:\PyProjects\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "Z:\PyProjects\venv\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Process finished with exit code 1