Python bindings for Selenium

0

I cannot install Selenium. I already have Python 3 and chromedriver. I am on a Windows 10 Desktop. This is what cmd tells me:

C:\Users\dani>pip install selenium
'pip' is not recognized as an internal or external command, operable program or batch file.

C:\Users\dani>sudo pip install selenium
'sudo' is not recognized as an internal or external command, operable program or batch file.

C:\Users\dani>pip3 install selenium
'pip3' is not recognized as an internal or external command, operable program or batch file.

C:\Users\dani>conda install selenium
'conda' is not recognized as an internal or external command, operable program or batch file.

dani

Posted 2019-05-31T12:12:32.323

Reputation: 1

1have you installed either pip or anaconda on your system? – Randomhero – 2019-05-31T15:04:15.533

Answers

0

The error you are recieving means that none of the base commands you are using (sudo, conda or pip) are registered with Windows for use at the command line.

Assuming that you selected the option to register python itself at the command line when you installed it, try python -m pip install -U selenium.

In this case:

  • python -m pip invokes the version of pip located in your Lib\site-packages\pip folder. -m means "module".

  • install -U selenium tells pip to install (and upgrade) Selenium. If you have never installed Selenium, it's fine to drop the -U option, but it won't hurt if you leave it in either.

Troubleshooting

On the off chance you get 'python' is not recognized as an internal or external command, operable program or batch file, you can:

  • Reinstall Python and select the option to register Python in your Windows PATH/Path variable(s) (arguably overkill).

  • Add python.exe to your PATH/Path variable(s) manually.

  • Use the full path to python in your command e.g. C:\Python37\python.exe -m pip install -U selenium.

Notes

Manually Adding Python To Your Path

To manually add python.exe to your Path variable in Windows 7 and Windows 10:

  1. Open the Start Menu Search box and type env.

  2. Choose the option to "Edit the system environment variables".

  3. In the dialog box that appear, click the "Environment Variables…" button at the bottom of the active tab.

  4. In the new dialog box that appears, look for the "System Variables" section in the lower half.

  5. Select the Variable (the first column) marked as "Path" (i.e. click on it), then click the "Edit..." button.

  6. In the "Edit environment variable" dialog box that appears, add a semicolon (;) to the end of the existing string, then add the full path to your python.exe (e.g. add C:\Python37\python.exe or similar). So the full string you append should look something like e.g. ;C:\Python37\python.exe.

  7. Click OK when finished.

Manually Installing Selenium

pip is simply an automated tool to download and install Python modules from the Python Packaging Index (PyPI) website. In this instance, it is pulling from the Selenium project hosted there.

However, if the options above are failing, you can download the correct Selenium package manually.

For the .whl (wheel) file, you would still use pip to install Selenium by opening a command window in the same directory and typing e.g. C:\Python37\python.exe -m pip install -U selenium (as above).

For the tar.gz file, you would fully extract the archive, open a command window in the extracted directory where setup.py resides, then run python setup.py install (or e.g. C:\Python37\python.exe setup.py install).

If you choose to manually download and install Selenium, pick one format or the other (i.e .whl or .tar.gz). It's likely worth mentioning that there is no practical difference between the two for your purposes.

Notes On Commands

  • sudo pip install selenium - sudo is a Linux command, so in order to even have a chance for this to work on Windows 10, you would need to be in the Windows Subsystem for Linux (WSL).

  • conda install selenium - conda is specific to Anaconda, which is a self-contained environment for Python.

  • pip install selenium - this can work if you installed vanilla Python for Windows from python.org. But pip.exe would still need to be registered at the command line (see steps for python.exe above and simply substitute the full path to pip.exe).

Anaksunaman

Posted 2019-05-31T12:12:32.323

Reputation: 9 278