I was doing a program that consisted of through these modules below create a new page on google, but it was not possible, because of some errors.
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
servico=Service(ChromeDriverManager().install())
navegador=webdriver.Chrome(service=servico)
This was the errors:
Traceback (most recent call last):
File "c:\\Users\\user\\Desktop\\Francisco\\trabalhos que não são da escola\\programação\\projeto1\\teste.py", line 2, in \<module\>
from webdriver_manager.chrome import ChromeDriverManager
File "C:\\Users\\user\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\webdriver_manager\\chrome.py", line 7, in \<module\>
from webdriver_manager.drivers.chrome import ChromeDriver
File "C:\\Users\\user\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\webdriver_manager\\drivers\\chrome.py", line 1, in \<module\>
from packaging import version
ModuleNotFoundError: No module named 'packaging'
I tried to reinstall all including "packaging" again but it didn´t work too.
What can I do?
CodePudding user response:
I can only guess here.
So, I guess your problem is with ChromeDriverManager
.
Try getting rid from it.
To do so, manually download the proper version of hromedriver.exe
and make your code pointing to that file explicitly.
As following:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
options = Options()
options.add_argument("start-maximized")
webdriver_service = Service('C:\webdrivers\chromedriver.exe')
driver = webdriver.Chrome(options=options, service=webdriver_service)
C:\webdrivers\chromedriver.exe
here is the actual location where I have chromedriver.exe
on my PC
CodePudding user response:
Try to execute the following commands in the terminal:
First:
pip install --upgrade pip
Second:
pip install packaging
If this doesn't help, try to reinstall the webdriver_manager package:
First:
pip uninstall webdriver_manager
Second:
pip install webdriver_manager