I've just installed Spyder IDE (only Spyder, not whole Anaconda) at work and would like to automate my work with FireFox.
My question is, how do I install the Selenium package?
I've just installed Spyder IDE (only Spyder, not whole Anaconda) at work and would like to automate my work with FireFox.
My question is, how do I install the Selenium package?
(Spyder maintainer here) First, you need to download Miniconda, create an environment and install Selenium on it with conda install selenium. Then you need to connect Spyder to your environment so you can run code that depends on Selenium on it.
The entire process is better described in the second part of our video about managing environments.
Install Python:
https://www.python.org/downloads/
Install Spyder:
https://www.spyder-ide.org/
Run PowerShell or CMD:
Insert following commands:
pip install selenium
pip install webdriver_manager
Use command "pip freeze", you should see among others, following libraries installed:
selenium==3.141.0
urllib3==1.26.2
webdriver-manager==3.2.2
Open Spyder -> Tools -> PYTHONPATH manager -> Add path
c:\users\Hronic\appdata\local\programs\python\python39\lib\site-packages
Note:
If you don't know the path, in CMD/PowerShell, type "PIP install selenium"
You will get the answer:
"Requirement already satisfied: urllib3 in c:\users\Hronic\appdata\local\programs\python\python39\lib\site-packages (from selenium) (1.26.2)"
Download webdriver - in my case mozilla:
https://github.com/mozilla/geckodriver/releases
In Spyder, you can type following code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox(executable_path=r'C:\Users\Hronic\Downloads\geckodriver.exe')
driver.get("http://www.python.org")
Note: