Nameerror: Name "Webdriver" Is Not Defined

Nameerror: Name "Webdriver" Is Not Defined

I have create a python script which requires the webdrive. In my code I have imported it like so, from selenium import webdriver.

I went to their website here downloaded and ran setup.py but still does not import it. I don't know if this helps but I have python 2.7, I also do not have installed pip.

0

3 Answers

This means that you have installed selenium package somewhere on your system, but the interpreter can not find it, either in the standard location, or the pythonpath override. Please try this in ipython or in Python2.7 shell:

import selenium
selenium.__file__

The above command statements should print out the path to the exact selenium folder that you import. If it not located in C:\Python27\Lib\site-packages (default Windows path for new package installation) then delete it or rename (if you don't really need it). Or just download selenium from another source that installs it to the standard location.

1

I'm new to coding and python as a whole but I was able to figure it out. At least what was giving me trouble.

in console: import selenium

from selenium import webdriver

then I was able to run: driver= webdriver.Chrome(executable_path=r'C:\webdrivers\chromedriver.exe')

chrome driver opened.

After you get the path to the driver, for instance, you can open Chrome via:

from selenium import webdriver
    
path = "C:\webdrivers\chromedriver.exe"
browser = webdriver.Chrome(path)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.