• Skip to primary navigation
  • Skip to main content

data Rebellion

Learning thru Adventure

  • Home
  • Blog
    • Learn Programming
      • Python
    • Use Programming
      • Web Scraping
    • Professional Development
  • Beginner Python Course
    • Preface – The Journey Ahead
    • Prologue – The Door
    • Chapter 1 – Arithmetic and Variables
    • Chapter 2 – Strings and Lists
    • Chapter 3 – Conditional Statements
    • Chapter 4 – Functions
    • Chapter 5 – Loops
    • Chapter 6 – Built-in Functions and Methods
    • Chapter 7 – Imports and Nesting
    • Chapter 8 – Opening the Door
    • Epilogue – Only the Beginning
  • About
  • Contact
You are here: Home / Use Programming / Web Scraping / Quick Guide to Installing Selenium (Google Chrome version)

Quick Guide to Installing Selenium (Google Chrome version)

Updated April 12, 2018. Published October 29, 2016. 7 Comments

To set up Selenium, you’ll first need to have Python installed. Check out my other posts if you need help with that.

Automating the Chrome browser with Python and Selenium

Next, you need to install Selenium. To do this, simply open up your Windows command prompt or Mac/Linux terminal and enter the command:

1
pip install selenium

Now that Selenium is installed, you need to pick a web browser for Selenium to use. Chrome and Firefox are both just as easy to use with Selenium, but here we’ll look at using Chrome. Assuming you have the Chrome browser installed on your machine, go to the following website:

https://sites.google.com/a/chromium.org/chromedriver/downloads

Follow the link to the latest release and download the appropriate driver for your machine. Unzip the driver and move it to whatever place in your file system you prefer. Just keep in mind you will need to reference the chrome driver’s location when you use Selenium.

Finally, to make sure everything is working as it should, run this code:

1
2
3
4
5
6
7
8
from selenium import webdriver
 
# your executable path is wherever you saved the chrome webdriver
chromedriver = "C:\\Users\\gstanton\\Downloads\\chromedriver.exe"
browser = webdriver.Chrome(executable_path=chromedriver)
 
url = "https://www.duckduckgo.com"
browser.get(url)

If a Chrome browser pops up and takes you to DuckDuckGo’s home page, you’re all set!

If something’s not working, make sure Selenium, Chrome, and chrome driver are all up-to-date and try again. If all else fails, leave a comment and we’ll figure it out.

Python Automation Project Ideas Ebook Front Page

Free Ebook: 88 Python Project Ideas for Automating Your Life

The best way to learn programming is by working on real-world projects, so why not work on projects that also save you time and sanity? In this free, curated collection, you'll find project ideas for automating:

  • Common office tasks
  • Birthday gifts and wishes
  • Grocery and meal planning
  • Relationships (just the tedious parts!)
  • And quite a bit more

Subscribe to Data Rebellion and get this Ebook delivered straight to your inbox, as well as other exclusive content from time to time on efficiently learning to code useful things, vanquishing soul-crushing work, and having fun along the way.

Tagged With: Selenium

Reader Interactions

Comments

  1. mark says

    September 7, 2017 at 6:20 am

    hey can you provide me a step by step installation for this. I followed the steps but when i try to install
    pip install selenium cmd promt me that pip is not recognized as an internal or external command…

    Reply
    • Grayson Stanton says

      September 7, 2017 at 6:31 pm

      Hey Mark,

      My guess is that Anaconda needs to be added to your PATH environment variable. During the Anaconda installation process, there is a screen that allows you to check a box to do this. It’s near the end of the process, as detailed here. It may be that this box was unchecked by default, and you moved past it without noticing. So if you want to, you can reinstall Anaconda and check that box. If you don’t want to go through installing it again, you can add Anaconda to your PATH manually as detailed here.

      Let me know if this doesn’t work.

      – Grayson

      Reply
  2. Julie says

    September 24, 2019 at 4:14 pm

    Finally! I’ve read 20 different threads to get my selenium to work with the newest chromedriver and it works. Thank you, thank you, thank you.

    Reply
    • Grayson Stanton says

      September 24, 2019 at 4:25 pm

      Thanks for your comment Julie, glad it helped!

      Reply
  3. Jason T. says

    January 10, 2020 at 2:59 am

    I installed selenium with pip3 on osx 10.12
    When I try to run a command to call it:

    install selenium

    I get an error:

    Sweetness:Desktop jason$ python bing.py
    Traceback (most recent call last):
    File “bing.py”, line 1, in
    import selenium
    ImportError: No module named selenium
    Sweetness:Desktop jason$ pip install selenium
    Requirement already satisfied: selenium in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (3.141.0)
    Requirement already satisfied: urllib3 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from selenium) (1.25.7)
    Sweetness:Desktop jason$ python

    Any chance someone can help?

    Thank you in advance!

    Reply
    • Grayson Stanton says

      January 10, 2020 at 6:03 pm

      Hi Jason. In the command you copied here, it looks like you used pip, not pip3, to install selenium. Maybe try pip3 install selenium if you haven’t already.

      Alternatively, maybe some of the solutions people propose here will prove helpful: https://stackoverflow.com/questions/31147660/importerror-no-module-named-selenium

      Reply
  4. Anonymous says

    January 10, 2020 at 6:07 pm

    Thanks for the reply – I figured it out. I have 2 versions of python on the system. Not sure how to remove the old one. But now things are working when I run: python3 ….

    Now I’m working through some other issues. But I think I’ll refrain until I’m truly stumped. It’s amazing how quickly I forget and then remember why I have mad respect for you coders. I could NEVER have the infinite patience required to do what you guys do! I wish I did. But alas…

    Thanks again for the reply!

    Reply

Leave a comment Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Header image graphic design credit: Ioan-Cosmin


Copyright © 2021

Terms and Conditions - Privacy Policy