jincept
jincept

Reputation: 279

ImportError for selenium for python

Python 3.4: I have installed selenium using this command on my Ubuntu:

sudo pip3 install selenium 

However, when I try to import, I get an error:

#!/usr/bin/env python3
from selenium import webdriver

Error - File "./selenium.py", line 2, in <module> from selenium import web driver

If I try to install the package again. it says it is already installed. I can see the package here, I can also see the webdriver directory there: /usr/local/lib/python3.4/dist-packages/selenium /usr/local/lib/python3.4/dist-packages/selenium-2.47.1.egg-info

This path is in my Python 3.4 environment variable. I have this working on my mac (Python3.4) but does not work on Ubuntu.

Any suggestions?

Upvotes: 1

Views: 322

Answers (2)

Anand S Kumar
Anand S Kumar

Reputation: 90889

As can be seen from the error message -

File "./selenium.py", line 2, in module
from selenium import web driver

you have named your file - selenium.py - this is masking the library module selenium , which is causing the issue.

You should rename your file to something else, such that it does not mask any libraries.

Also, in the code you pasted, there is no space between web and driver but in the error message there seems to be a space, if the space is really there in the code, then remove the space as well. It should be -

from selenium import webdriver

Upvotes: 2

user3299890
user3299890

Reputation: 23

You seem to have a space in web driver. Please change it to webdriver.

Error - File "./selenium.py", line 2, in <module>
from selenium import web driver

Also, your file is named selenium and your module is named selenium. These two names are conflicting.

Upvotes: 0

Related Questions