2

I've just installed Selenium (I'm that new to it) for Python using

sudo -H pip install selenium

and at the following command

from selenium.webdriver import Firefox 

I get

No module named webdriver

Any thoughts?

9
  • Can you import selenium and check whether selenium.__file__ points to correct folder that actually contains webdriver? Commented Oct 12, 2016 at 8:51
  • Tried the same import here and nothing seems wrong. Does just import selenium also result in an error? Commented Oct 12, 2016 at 9:04
  • Why use H flag on sudo? Commented Oct 12, 2016 at 9:05
  • Was also wondering about the sudo -H flag. I never needed to use it. Commented Oct 12, 2016 at 9:07
  • I used the H flag because my Ubuntu system suggested it when I initially installed Commented Oct 12, 2016 at 9:19

3 Answers 3

2

Most probably your Python file is called

selenium.py

Python interpreter at first tries to import files from directory you're in, so the solution is to rename the executed file and issue will be gone.

Sign up to request clarification or add additional context in comments.

Comments

0

Check if site packages link is added in system environment variables;

C:\Python27\Lib\site-packages;

On windows start, type environment variables. Click on the "Edit the system environment variables" . Click -> Environment variables -> Under System Variables-> Scroll down to find "Path" -> Edit and add above path.

1 Comment

Sorry, I don't understand
-1

first you need to import

from selenium import webdriver

then you can use other imports

8 Comments

This is not required. Why do you think so?
if I do not import above then my script will not know what webdriver is...thats why its important
My code works without first importing webdriver separately, which makes sense to me. When you are right, this would mean you always need to import each level of the package hierarchy.
without import at all how you script understand what you are talking is, for selenium ...I am talking about python
@thebadguy, If you do from selenium.webdriver import Firefox you should use it as driver = Firefox()! It's normal that you cannot call it as webdriver.Firefox() as you import Firefox class separately from webdriver module
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.