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/Pyt
It's 2020 now, use python3 consistently
I meet the same problem when I install selenium using pip3
, but run scripts using python
.
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!
I had the exact same problem and it was driving me crazy (Windows 10 and VS Code 1.49.1)
Other answers talk about installing Selenium, but it's clear to me that you've already did that, but you still get the ImportError: No module named 'selenium'
.
So, what's going on?
Two things:
The solution? You have to install selenium in the same directory to the Python version you're using or change the interpreter to match the directory where Selenium is installed.
In VS Code you change the interpreter here (at the bottom left corner of the screen)
Ready! Now your Python interpreter should find the module.
make easy install again by downloading selenium webdriver from its website it is not installed properly.
Edit 1: extract the .tar.gz folder go inside the directory and run python setup.py install from terminal.make sure you have installed setuptools.
install urllib3
!pip3 install urllib3
import urllib3
than install it
!pip3 install selenium
import selenium
I had the same problem. Using 'sudo python3 -m pip install selenium' may work.