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
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
I solved it by reinstalling the older version of selenium package because the newest version doesn't support Python 2.6.6 which in my case was installed and I didn't have root access to install the new one.
While the newest version of selenium package doesn't have support for Python 2.6.6, I had to downgrade by reinstalling the selenium package with lower version
pip uninstall selenium
pip install --user selenium==3.5.0
Deepa, it is likely a 'path not found' issue. Add as many paths as relevant to help the IDE find selenium and webdriver. For example, on my Mac, I've added all the following paths so nothing is missed :
file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5 file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium-3.0.0b2/py file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium-3.0.0b2/py/selenium file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium-3.0.0b2/py/selenium/common file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium-3.0.0b2/py/selenium/webdriver
First, you must install the selenium
by using pip
or pipenv
:
pip install selenium
If your file name is selenium.py
, change it to something else and delete .pyc
files or the __pycache__
directory if exists.
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 ?