0
votes
Installed selenium using pip : pip install selenium<br>
pip version : pip 8.1.2 from /usr/local/lib/python2.7/site-packages (python 2.7)<br>

python version : Python 2.7.5

Wasn't getting this error earlier.

"ImportError: No module named selenium"

Upgraded pip a while ago and started getting this error. Couldn't find anything useful from earlier questions.

sys.path:
['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages']

Can anyone please help?

1
where is your code?Yu Zhang
Do you know the directory where selenium was installed before? Does that directory still exist?John Gordon
where this error occur? your code before this import error.Yu Zhang
@JohnGordon I don't remember the earlier directory...Currently it is in : /usr/local/lib/python2.7/site-packagesvedaanta
Try this code: import sys; print(sys.path) Is /usr/local/lib/python2.7/site-packages in the output?John Gordon

1 Answers

2
votes

Please check if you have multiple python interpreters in your machine.

check what is your default interpreter by python in your terminal and press ENTER.

if it is same as the version mentioned y PIP while installing, you should not have any problems.

or else,

change your default interpreter by keeping alias in your bash file,

append below line as last line as per your interpreter version

alias python='/usr/bin/python2.7.6'