Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named 'selenium'

I'm trying to write a script to check a website. It's the first time I'm using selenium. I'm trying to run the script on a OSX system. Although I checked in /Library/Python/2.7/site-packages and selenium-2.46.0-py2.7.egg is present, when I run the script it keeps telling me that there is no selenium module to import.

This is the log that I get when I run my code:

Traceback (most recent call last):   File "/Users/GiulioColleluori/Desktop/Class_Checker.py", line 10, in <module>     from selenium import webdriver ImportError: No module named 'selenium' 
like image 266
Giulio Colleluori Avatar asked Jun 30 '15 20:06

Giulio Colleluori


People also ask

How do I fix No module named selenium error in Python 3?

The Python "ModuleNotFoundError: No module named 'selenium'" occurs when we forget to install the selenium module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install selenium command.

How do I import selenium into Python?

To install the Selenium bindings in our system, run the command: pip install selenium. As this is done, a folder called Selenium should get created within the Python folder. To update the existing version of Selenium, run the command: pip install –U selenium.


1 Answers

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!

like image 149
gffbss Avatar answered Sep 22 '22 16:09

gffbss