Recently I installed Anaconda to learn more about it and the first thing I was about to try was opening a web page automatically, using Selenium.
So, to perform this, I used Jupyter and tried to import the Selenium webdriver. Up to this point, everything went well, but when I ran my code using Jupyter Notebook, I got an error: ‘No module named ‘selenium’.
The strange thing is, I got an error, although I have got Selenium installed on my machine using pip with the below command:
Now what could be the reason?
To analyze it further, I wrote the same Python code in Visual Studio and ran it. It worked perfectly well.
So, I just thought to try to check the version of Selenium and first I tried it with pip as shown below,
As the above message says, it is already installed and didn’t contain anything. So, next I thought to try with the Anaconda command prompt as shown below,
Did you notice that rectangle marked with orange? Yes, that was the culprit that was not allowing my code to work. There was a difference in versions and as Jupyter was launched from Anaconda, it was not able to get the correct version.
Once the above code ran, I was successfully able to run my below code.
I hope this trick will save you hours.