0

This is not a duplicate as I used the previous solutions but did not solve the problem.

I need to install Selenium in python. I used this command as suggested in previous solution:

python -m pip install -U selenium

This is the output I get:

Collecting selenium
  Downloading https://files.pythonhosted.org/packages/80/d6/4294f0b4bce4de0abf13e17190289f9d0613b0a44e5dd6a7f5ca98459853/selenium-3.141.0-py2.py3-none-any.whl (904kB)
    100% |████████████████████████████████| 911kB 1.5MB/s 
Collecting urllib3 (from selenium)
  Using cached https://files.pythonhosted.org/packages/62/00/ee1d7de624db8ba7090d1226aebefab96a2c71cd5cfa7629d6ad3f61b79e/urllib3-1.24.1-py2.py3-none-any.whl
Installing collected packages: urllib3, selenium
Successfully installed selenium-3.141.0 urllib3-1.24.1

I then try to run a python code:

python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from selenium import webdriver

But I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'selenium'
>>> 
Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
user9371654
  • 2,160
  • 16
  • 45
  • 78
  • propably you have few versions of python installed, try to use `python3 -m pip install -U selenium` – Robert Feb 15 '19 at 10:07

4 Answers4

2

The problem may be the fact that you are installing it into python2 by running python -m pip install -U selenium. Some devices such as Macs use python2 and in order to run python3 commands you can either add an alias alias python=python3 in your .bashrc or .zshrc file or you can run them with the prefix python3.

Try running python3 -m pip install -U selenium.

If this gives you access denied run it with sudo: sudo -H python3 -m pip install -U selenium

Hope this helps :)

aaaakshat
  • 809
  • 10
  • 19
1

You have to check if you use same pip that is provided alongside your python. To check it, use which.

$ which python3                                                                                                                                                                      
>> /usr/local/bin/python3
$ which pip3                                                                                                                                                                         
>> /usr/local/bin/pip3

If they are on same location you can use:

pip3 install selenium
jozo
  • 4,232
  • 1
  • 27
  • 29
0

It's possible you have a different version of Python(possible 2.7.x) installed on the the same computer. In such a case, you need to change directory to the Scripts folder of the python version you want it installed. Kindly reply, for more instructions.

Joel Jogy
  • 17
  • 5
0

"python3 -m pip install -U selenium" fixed the problem for me. Thanks.

Zinou
  • 1