ImportError: No module named 'selenium' in PyCharm
Asked Answered
C

4

7

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

Conscious answered 19/2, 2019 at 7:23 Comment(1)
in terminal do pip install webdriverHeadachy
P
19

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

Ph answered 19/2, 2019 at 7:27 Comment(5)
Thank you for the solution, i tried first one and it worked for me but it started throwing me another Error : Traceback (most recent call last): File "C:/Users/aman.k/PycharmProjects/SeleniumScripts/MyFirstSeleniumScript.py", line 4, in <module> driver = webdriver.chrome("E:\\Work\\workspace\\chromedriver.exe") TypeError: 'module' object is not callable.Conscious
@AmanKumar make a new question and insert a screenshot so to understand what your problem is :) After the question gives me here the link so to see it. Because is something completely different and can not be in the same question :)Ph
Okay @dpap thank you for your guidance, i will create a new question for that problem and also thank you for the helping me to resolve this issue.Conscious
@Aman Kumar paste here the link of your new question so that I will see it and help you. Anytime :)Ph
Thank you @dpap Your solution really helped me to solve my problem very easily, regarding my previous question i was unable to get the path of chrome driver and i have reinstalled the chrome driver in my system and the issue got resolved.Conscious
B
2

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.

Beggs answered 19/2, 2019 at 7:53 Comment(0)
F
0

You may have it installed in a different env and running pycharm from a different env. The best solution is to go to file then setting then your project and python interpreter. Click on the small + sign and search pycharm and finally click on install to install it. It should work now.

Fotheringhay answered 25/4, 2021 at 18:46 Comment(0)
M
0

i had the same issue, but i was unable to install packages so i tried to change the interpreter and that too failed so i deleted the existing venv and then it automatically selected the default python, and the problem was solved. I don't know it is the right way or not but it was the only way i found.

Marlin answered 14/12, 2023 at 13:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.