Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named 'selenium' in PyCharm

I have installed all the file and packages like python, pip, selenium and i am running a python code in PyCharm, but it is still showing me this error whenever i run my code.

Error showing while running python file.

Traceback (most recent call last): File "C:/Users/aman.k/PycharmProjects/SeleniumScripts/MyFirstSeleniumScript.py", line 3, in import webdriver ModuleNotFoundError: No module named 'webdriver'

Code running environment:

  • Windows OS 8.1
  • Python 3.7.2
  • pip 19.0.2

Here is my code which i am trying to run.

enter image description here

like image 750
Aman Kumar Avatar asked Feb 19 '19 07:02

Aman Kumar


People also ask

How do I fix No module named selenium error in Python 3?

The Python "ModuleNotFoundError: No module named 'selenium'" occurs when we forget to install the selenium module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install selenium command.

How do I import selenium into Python?

To install the Selenium bindings in our system, run the command: pip install selenium. As this is done, a folder called Selenium should get created within the Python folder. To update the existing version of Selenium, run the command: pip install –U selenium.


2 Answers

From your screenshot, I can see that selenium is not installed. Please follow the next step:

1st solution:

File -> Settings -> Inside your project's name -> Project Interpreter -> click on "+" button -> search for selenium (current version 3.141.0) -> click on install -> restart PyCharm.

2nd solution:

Or click on the selenium word from the first line (from the import) and wait until a solution will be shown. The solution will say install selenium package. Press on it and you are done.

Screenshot for solution 2:

enter image description here

3rd solution:

If you have already installed the selenium then you need to install webdirver. Follow the following screenshot to solve it.

Screenshot for 3rd solution:

enter image description here

like image 75
dpapadopoulos Avatar answered Oct 16 '22 10:10

dpapadopoulos


Pychram can use more than one environment for running your project. I guess you are using a different environment in which you have installed tools. Change the env by going

File > Settings > Prefrences > Project Interpreter.

Either change that to the local env or click + button below the window and add that package to current env.

like image 25
Ravi Singh Avatar answered Oct 16 '22 09:10

Ravi Singh