Error: No module named selenium

6,400 views
Skip to first unread message

finspin

unread,
Aug 17, 2012, 8:05:49 AM8/17/12
to robotframe...@googlegroups.com
I'm getting the below error when I'm trying to run a test case. I installed Selenium2Library but it looks like RF can't find it. Everything works fine with SeleniumLibrary.

Selenium2Library is installed in C:\Python27\lib\site-packages. I uninstalled and installed it a few times to make sure the installation is correct. There were no errors during the installations.

Any ideas where to look for the problem?

Here is the error:

c:\testing>pybot testone.txt
[ ERROR ] Error in file 'c:\testing\testone.txt' in table 'Settings': Importing test library 'Selenium2Library' failed: ImportError: No module named selenium
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\Selenium2Library\__init__.py", line 2, in <module>
    from keywords import *
  File "C:\Python27\lib\site-packages\Selenium2Library\keywords\__init__.py", line 3, in <module>
    from _browsermanagement import _BrowserManagementKeywords
  File "C:\Python27\lib\site-packages\Selenium2Library\keywords\_browsermanagement.py", line 4, in <module>
    from selenium import webdriver
PYTHONPATH:
  C:\Python27\lib\site-packages\robot\libraries
  C:\Python27\lib\site-packages
  C:\Windows\system32\python27.zip
  C:\Python27\DLLs
  C:\Python27\lib
  C:\Python27\lib\plat-win
  C:\Python27\lib\lib-tk
  C:\Python27
  C:\Python27\lib\site-packages\wx-2.8-msw-unicode

Ed Manlove

unread,
Aug 17, 2012, 3:36:48 PM8/17/12
to jaros...@gmail.com, robotframe...@googlegroups.com
> --

You are missing at least one of robotframework-selenium2library's
dependencies, selenium, which is another python package. It is
recommended that you install robotframework-selenium2library via pip
(using the command 'c:\pip install robotframework-selenium2library')
which installs robotframework-selenium2library and all of it's
dependencies. But given your error I am assuming you used easy_install
which is fine but under windows os (which your traceback indicates that
is the OS you are using) easy_install does ***not*** install
dependencies. So to rectify your error you need to install selenium
using a command like

c:\ easy_install selenium

You should have also installed the other dependencies, docutils and
decorator; possibly using commands like

c:\ easy_install decorator
c:\ easy_install docutils

And if you downloaded the source zip files from PyPI then you should do
the same for decorator, docutils, selenium. But once again under windows
it is recommended to install using pip. We are planning on upgrade the
documentation to better clarify this and any feedback is appreciated.

Ed

finspin

unread,
Aug 18, 2012, 1:27:41 AM8/18/12
to robotframe...@googlegroups.com, jaros...@gmail.com
Ed, thanks for your answer. I installed other dependencies as you recommended. I also reinstalled selenium2library using pip by doing "pip install robotframework-selenium2library". I think I moved forward but still getting an error. The current error is:

c:\testcases>pybot test.txt
[ ERROR ] Error in file 'C:\resources\resources.txt' in table 'Settings': Importing test library 'Selenium2Library' failed: IOError: [Errno 2] No such file or directory: 'C:\\Python27\\lib\\site-packages\\Selenium2Library\\..\\..\\version.py'

Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\Selenium2Library\__init__.py", line 5, in <module>
    execfile(os.path.join(THIS_DIR, '..', '..', 'version.py'))

PYTHONPATH:
  C:\Python27\lib\site-packages\robot\libraries
  C:\Python27\lib\site-packages
  C:\Python27\lib\site-packages\selenium-2.25.0-py2.7.egg
  C:\Python27\lib\site-packages\decorator-3.3.3-py2.7.egg
  C:\Python27\lib\site-packages\docutils-0.9.1-py2.7.egg
  C:\Python27\lib\site-packages\pip-1.1-py2.7.egg

  C:\Windows\system32\python27.zip
  C:\Python27\DLLs
  C:\Python27\lib
  C:\Python27\lib\plat-win
  C:\Python27\lib\lib-tk
  C:\Python27
  C:\Python27\lib\site-packages\wx-2.8-msw-unicode

Ed Manlove

unread,
Aug 18, 2012, 8:46:11 AM8/18/12
to jaros...@gmail.com, robotframe...@googlegroups.com
Looking at the first line of the traceback, it looks like you have an
older version of Selenium2Library. Did you delete the old library in
between re-installing with pip? I'm not sure what Windows does if you
first install via easy_install then install with pip without deleting.
There are a couple of things I would try.

First you can use the pip --upgrade flag which is used when you wish to
upgrade a python package to it's recent version. Try

C:\> pip install --upgrade robotframework-selenium2library

This should update you package although (again I am not sure how pip /
Windows deals with a possible "dirty" or easy_install install). You
should see either a directory like
C:\Python27\lib\site-packages\robotframework-1.0.1-py2.7.egg or a
version file, C:\Python27\lib\site-packages\Selenium2Library\version.py
containing "VERSION = '1.0.1'". Retry c:\>pybot test.txt and ff this
doesn't work I would delete the directory,
C:\Python27\lib\site-packages\Selenium2Library, and reinstall then try
again.

Ed

finspin

unread,
Aug 18, 2012, 3:03:47 PM8/18/12
to robotframe...@googlegroups.com, jaros...@gmail.com
Removing Selenium2Library folder and reinstalling it with pip solved the problem. I also tried upgrading the library but that did not work.

Thanks a lot for your help with this!
Reply all
Reply to author
Forward
0 new messages