ModuleNotFoundError: No module named selenium error occurs if the selenium module is not properly installed or not configured properly. Selenium library provides features to automate the browser which has multiple use cases like automation testing, backend to virtual assistant, etc. Selenium comes with multi-programming language support like Java, Python, etc. In this article, we will specifically focus on solving the error No module named selenium with Python Interpreter.
ModuleNotFoundError: No module named selenium ( Solution ) –
The best solution is to install or reinstall selenium package to fix this error. But how?
Solution 1: Use pip to install selenium –
Use the below command to use pip for selenium installation.
pip install selenium
Optional Scenario :
1.1. In case the system needs admin privileges to run the above pip command for selenium installation. Then add sudo keyword at the beginning of the command for the Linux family OS. If you are using a Window-based OS, open the command prompt and run the above command only.
sudo pip install selenium
1.2 If you need to install any specific version for selenium all we need to mention in the same command.
pip install selenium==4.5.0
Regarding different versions of selenium with pip, refer selenium release notes on PyPI.
1.3 In case pip is outdated or failing then use the below command as a prerequisite before you run any of the above commands.
python -m ensurepip --default-pip python -m pip install --upgrade pip setuptools wheel pip install selenium
1.4 if the path is not set for pip itself then run the below command.
python -m pip install selenium
Solution 2: Use conda to install selenium –
Similar to pip we can use conda to install selenium with the below command.
conda install -c conda-forge selenium
Solution 3: Use source code to install selenium –
Installation for scratch. For this we need the download the source code. Since this source code is generic and has an implementation for multiple programming languages like java, python. Hence we need to first navigate into the Py folder and then build the wheel or any other binding format.
Join our list
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.