Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'webdriver'

Tags:

python

I am a newbie for selenium python. I have installed python, pip etc.. I am trying to run the below code but it is showing error:

ImportError: cannot import name 'webdriver'

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://www.python.org")

could anyone please solve this issue?

like image 249
Deepa Avatar asked Mar 17 '15 06:03

Deepa


4 Answers

If your file name is selenium.py, change it to something else and delete .pyc files or the __pycache__ directory if exists.

If you do not have the selenium, you should install the selenium by using pip or pipenv:

pip install selenium
like image 52
Mesut GUNES Avatar answered Oct 24 '22 23:10

Mesut GUNES


It says that webdriver cant be import.So I assume you have Selenium installed.

So I can only assume that the selenium lied in different place in your path.

Maybe you have accidently create a file named selenium ?

like image 22
amow Avatar answered Oct 24 '22 23:10

amow


  1. if your file is selenium.py rename it.
  2. Pay attention to have import Keys instead of import keys
like image 9
Matheew Avatar answered Oct 25 '22 00:10

Matheew


Step 1: First rename filename if saved with selenium.py and delete selenium.pyc. mv selenium.py test.py rm selenium.pyc Step 2: import module selenium if not already installed. pip install selenium

like image 7
deepak Avatar answered Oct 25 '22 01:10

deepak