Open basu021 opened 2 years ago
Traceback (most recent call last): File "C:\Users\Basu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\selenium\webdriver\common\service.py", line 72, in start self.process = subprocess.Popen(cmd, env=self.env, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64qbz5n2kfra8p0\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64qbz5n2kfra8p0\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 "C:\Users\Basu\Documents\GitHub\whazzap\app.py", line 4, in browser = webdriver.Firefox() File "C:\Users\Basu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\selenium\webdriver\firefox\webdriver.py", line 142, in init self.service.start() File "C:\Users\Basu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\selenium\webdriver\common\service.py", line 79, in start raise WebDriverException( selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
The error message you are getting indicates that the Selenium driver for Firefox, called geckodriver, is not in your PATH environment variable. This means that when Selenium tries to start Firefox, it cannot find the geckodriver executable.
There are two ways to fix this error:
Add geckodriver to your PATH environment variable. This is the recommended solution, as it will allow Selenium to find geckodriver automatically. To do this, follow these steps:
Open the Control Panel. Click on System and Security. Click on System. Click on Advanced system settings. In the Environment Variables dialog box, scroll down to the Path variable and click on Edit. Add the directory where geckodriver is installed to the end of the Path variable, separated by a semicolon. Click OK to close all dialog boxes. Specify the path to geckodriver when you start Selenium. You can do this by passing the executable_path argument to the webdriver.Firefox() constructor. For example: ''' from selenium import webdriver browser = webdriver.Firefox(executable_path='C:/path/to/geckodriver.exe')
''' you can download the geckodriver executable from the following link: geckodriver download page: https://github.com/mozilla/geckodriver/releases
Once you have downloaded geckodriver, extract it to a directory on your computer. Then, follow the instructions above to add it to your PATH environment variable or to specify the path to it when you start Selenium.
''' from selenium import webdriver
import os os.environ['PATH'] += ';C:/path/to/geckodriver'
browser = webdriver.Firefox(executable_path='C:/path/to/geckodriver.exe') '''
Traceback (most recent call last): File "C:\Users\Basu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\selenium\webdriver\common\service.py", line 72, in start self.process = subprocess.Popen(cmd, env=self.env, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64qbz5n2kfra8p0\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64qbz5n2kfra8p0\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 "C:\Users\Basu\Documents\GitHub\whazzap\app.py", line 4, in
browser = webdriver.Firefox()
File "C:\Users\Basu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\selenium\webdriver\firefox\webdriver.py", line 142, in init
self.service.start()
File "C:\Users\Basu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\selenium\webdriver\common\service.py", line 79, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.