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:
conda create -n yourenvname python=x.x anaconda
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
Import Error: No Module Name Urllib2
Run Certain Code Every N Seconds
How to Run Multiple Python Versions on Windows
Class Method Differences in Python: Bound, Unbound and Static
How to Find the Time Difference Between Two Datetime Objects in Python
Matplotlib Different Size Subplots
Replacing Instances of a Character in a String
How to Determine a Python Variable's Type
What's the Best Way to Parse a JSON Response from the Requests Library
How to Convert a String with Dot and Comma into a Float in Python
Convert Pandas Column Containing Nans to Dtype 'Int'
What Is the Most Efficient Way to Loop Through Dataframes with Pandas
How to Hide the Console When I Use Os.System() or Subprocess.Call()