Issue
I'm running a selenium file with the following code in python and I keep having a traceback call error. I can't tell what the problem is. Below is the error I keep having:
[Traceback (most recent call last): File "C:\Users\Whizzy.Ellah\PycharmProjects\virtual_assistant_final_year_project\selenium_web.py", line 2, in from selenium import webdriver File "C:\anacondaF\envs\finalYrProject\lib\site-packages\selenium\webdriver_init_.py", line 18, in from .firefox.webdriver import WebDriver as Firefox # noqa File "C:\anacondaF\envs\finalYrProject\lib\site-][1]Traceback (most recent call last):
File "C:\Users\Whizzy.Ellah\PycharmProjects\virtual_assistant_final_year_project\selenium_web.py", line 2, in <module>
from selenium import webdriver
File "C:\anacondaF\envs\finalYrProject\lib\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox # noqa
File "C:\anacondaF\envs\finalYrProject\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 26, in <module>
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
File "C:\anacondaF\envs\finalYrProject\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 40, in <module>
from .remote_connection import RemoteConnection
File "C:\anacondaF\envs\finalYrProject\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 26, in <module>
import urllib3
ModuleNotFoundError: No module named 'urllib3'
Process finished with exit code 1
My code:
import time
from selenium import webdriver
from selenium.webdriver import chrome
class web_driver_info():
def __int__(self):
self.driver = webdriver.Chrome(executable_path=r'C:\\Users\\Whizzy.Ellah\\PycharmProjects\\virtual_assistant_final_year_project\\chromedriver.exe')
def get_info(self, query):
self.query = query
self.driver.get(url='https://www.wikipedia.org')
class_instance = web_driver_info()
class_instance.get_info("Hello")
Solution
This is what finally worked for me
I tried changing the virtual environment from anaconda to python virtual environment by deactivating the anaconda virtual env that is being used by typing conda deactivate finalYrProject
(finalYrProject is the name of my virtual environment) through the anaconda command prompt.
Also, I had to change the base interpreter - i.e Python interpreter by clicking on the file tab in Pycharm > settings > Python interpreter > settings' icon near the already used python interpreter selected > Show All and selected from the list of Python interpreters I had. And after running the code again everything works fine.
Answered By - Whizzy Ellah
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.