Python:No Module Named Selenium

ImportError: No module named 'selenium'

If you have pip installed you can install selenium like so.

pip install selenium

or depending on your permissions:

sudo pip install selenium

For python3:

sudo pip3 install selenium

As you can see from this question pip vs easy_install pip is a more reliable package installer as it was built to improve easy_install.

I would also suggest that when creating new projects you do so in virtual environments, even a simple selenium project. You can read more about virtual environments here. In fact pip is included out of the box with virtualenv!

How to solve No module named 'selenium' in VS code?

Both answers above might work but it is better to create a virtual environment and install your dependencies in there. Since you're already using Anaconda, I'll list the steps below.

You can create a virtual environment with Anaconda:

  1. conda create -n yourenvname python=x.x anaconda
  2. source activate yourenvname

You can find more info how to setup your environment here

ImportError: No module named 'selenium' error in my script

You must install Selenium. Open the command prompt and run the following command to install selenium:

pip install selenium

No module named 'selenium.webdriver.common.by'' Error in Selenium Python

Hi Please correct the line it is "find_element_by_class_name"

main = driver.find_element_by_class("reg-mark-sm")

to

main = driver.find_element_by_class_name("reg-mark-sm")

here is the complete code

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

PATH = "C:/Users/josh.bailey/Documents/chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get ("https://vehicleenquiry.service.gov.uk/")
time.sleep(5)
search = driver.find_element_by_id("wizard_vehicle_enquiry_capture_vrn_vrn")
search.send_keys("*REDACTED*")
search.send_keys(Keys.RETURN)
time.sleep(5)
main = driver.find_element_by_class_name("reg-mark-sm")
print(main.text)
driver.quit()

Python: ImportError: No module named Selenium Windows

I am very sorry for this... but it just worked by running it with:

python main.py


Related Topics



Leave a reply



Submit