2

When I install Selenium I get the following error:

Shubham@Shubham-To-be-filled-by-O-E-M:~$ sudo apt-get update
    Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]
    Hit:2 https://repo.skype.com/deb stable InRelease                       
    Hit:3 http://in.archive.ubuntu.com/ubuntu xenial InRelease                     
    Get:4 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
    Get:5 http://in.archive.ubuntu.com/ubuntu 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 main

How should I proceed?

3

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.x

and/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 https://github.com/mozilla/geckodriver/releases/download/v0.20.1/geckodriver-v0.20.1-linux64.tar.gz
tar xvfz geckodriver-v0.20.1-linux64.tar.gz
mv geckodriver ~/.local/bin
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.