I want to install selenium webdriver in my Ubuntu 16.04 system for python
By Jessica Wood •
When I install Selenium I get the following error:
Shubham@Shubham-To-be-filled-by-O-E-M:~$ sudo apt-get update Get:1 xenial-security InRelease [107 kB] Hit:2 stable InRelease Hit:3 xenial InRelease Get:4 xenial-updates InRelease [109 kB] Get:5 xenial-backports InRelease [107 kB] Fetched 323 kB in 8s (38.6 kB/s) Reading package lists... Done Shubham@Shubham-To-be-filled-by-O-E-M:~$ sudo pip install selenium Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module> from pip import main ImportError: cannot import name mainHow should I proceed?
2 Answers
Selenium is available from the default Ubuntu repositories in Ubuntu 16.04 and later. To install selenium open the terminal and type:
sudo apt install python-selenium # for Python 2.xand/or
sudo apt install python3-selenium # for Python 3.x Then type python to start the Python interpreter and from selenium import webdriver should work like this:
$ python >>> from selenium import webdriver
Assuming that the path ~/.local/bin is in your execution PATH, here's how to install the Firefox webdriver, called geckodriver:
wget
tar xvfz geckodriver-v0.20.1-linux64.tar.gz
mv geckodriver ~/.local/bin To install a specific version go to pypi.
Find a version you need from the Release history and on the example of tag 4.0.0.a7 run:
pip install selenium==4.0.0.a7The same works for Ubuntu 20.04.