SeleniumLibrary icon indicating copy to clipboard operation
SeleniumLibrary copied to clipboard

Decorator module not found

Open preshri opened this issue 14 years ago • 16 comments

I have installed Selenium2 library with Robot framework and Ride and have configured corresponding Path variables. I wrote a simple test to open a browser. However on Run i get the foll error. Kindly clarify

[ ERROR ] Error in file 'D:\py 2.7\Scripts\testRide\testride1.txt' in table 'Settings': Importing test library 'D:/py 2.7/Lib/site-packages/Selenium2Library' failed: ImportError: No module named decorator PYTHONPATH: ['D:\py 2.7\Lib\site-packages\robot\libraries', 'D:\py 2.7\Lib', 'D:\py 2.7\Scripts', 'D:\py 2.7\Lib\site-packages', 'D:\py 2.7\Lib\site-packages\Selenium2Library', 'D:\py 2.7\Lib\site-packages\robotide', 'D:\py 2.7\Lib\site-packages\wx-2.8-msw-unicode', 'C:\WINNT\system32\python27.zip', 'D:\py 2.7\DLLs', 'D:\py 2.7\lib\plat-win', 'D:\py 2.7\lib\lib-tk', 'D:\py 2.7', 'D:\py 2.7\Lib\site-packages\robot', '.'] Traceback (most recent call last): File "D:\py 2.7\Lib\site-packages\robot\utils\importing.py", line 84, in non_dotted_import module = import_module_by_path(name) File "D:\py 2.7\Lib\site-packages\robot\utils\importing.py", line 38, in import_module_by_path module = import(modname) File "D:\py 2.7\Lib\site-packages\Selenium2Library__init.py", line 2, in from keywords import * File "D:\py 2.7\Lib\site-packages\Selenium2Library\keywords__init_.py", line 1, in from _logging import _LoggingKeywords File "D:\py 2.7\Lib\site-packages\Selenium2Library\keywords_logging.py", line 5, in from keywordgroup import KeywordGroup File "D:\py 2.7\Lib\site-packages\Selenium2Library\keywords\keywordgroup.py", line 4, in from decorator import decorator

preshri avatar Mar 13 '12 16:03 preshri

preshri,

It looks like you need to install the decorator package, http://pypi.python.org/pypi/decorator/3.3.2. I'm not too familiar yet with windows installations but you can use easy_install, if available, or download the source package, from PyPI and install using python. Both methods are documented on the decorator package PyPI website.

Also with the latest 1.0.0 release of robotframework-selenium2library if you install robotframework-selenium2library using easy_install it should also install the necessary dependencies. - Ed

emanlove avatar Mar 14 '12 00:03 emanlove

@preshri how did u install selenium2library?

j1z0 avatar Mar 14 '12 07:03 j1z0

The same thing happened to me on two different machines, both 64 bit Windows 7 (one Enterprise and one Home Premium)

Steps to reproduce:

  1. Install http://www.python.org/ftp/python/2.7.2/python-2.7.2.amd64.msi
  2. Install http://code.google.com/p/robotframework/downloads/detail?name=robotframework-2.6.3.win-amd64.exe&can=2&q= or http://code.google.com/p/robotframework/downloads/detail?name=robotframework-2.7rc1.win-amd64.exe&can=2&q= does not matter which one
  3. Install https://github.com/downloads/rtomac/robotframework-selenium2library/robotframework-selenium2library-1.0.0.win-amd64.exe
  4. Set up PATH env. variables, verify that python and pybot both respond when called from CLI.
  5. Create really simple test, no matter what it contains, import Selenium2Library to that
  6. Run the test

easy_install does not seem to work with 64 bit Python on Windows (http://pypi.python.org/pypi/setuptools), maybe that is the reason?

Harri avatar Mar 14 '12 08:03 Harri

Same thing happened when installed 32 bit versions of Python, RF and Selenium2Library.

Harri avatar Mar 14 '12 08:03 Harri

@emanlove - The "decorator module not found" issue is not seen now after installing the decorator package, however I am displayed the foll error. [ ERROR ] Error in file 'D:\py 2.7\Scripts\testRide\testride1.txt' in table 'Settings': Importing test library 'D:/py 2.7/Lib/site-packages/Selenium2Library' failed: ImportError: No module named selenium PYTHONPATH: ['D:\py 2.7\Lib\site-packages\robot\libraries', 'D:\py 2.7\Lib', 'D:\py 2.7\Scripts', 'D:\py 2.7\Lib\site-packages', 'D:\py 2.7\Lib\site-packages\Selenium2Library', 'D:\py 2.7\Lib\site-packages\robotide', 'D:\py 2.7\Lib\site-packages\wx-2.8-msw-unicode', 'C:\WINNT\system32\python27.zip', 'D:\py 2.7\DLLs', 'D:\py 2.7\lib\plat-win', 'D:\py 2.7\lib\lib-tk', 'D:\py 2.7', 'D:\py 2.7\Lib\site-packages\robot', '.'] Traceback (most recent call last): File "D:\py 2.7\Lib\site-packages\robot\utils\importing.py", line 84, in non_dotted_import module = import_module_by_path(name) File "D:\py 2.7\Lib\site-packages\robot\utils\importing.py", line 38, in import_module_by_path module = import(modname) File "D:\py 2.7\Lib\site-packages\Selenium2Library__init.py", line 2, in from keywords import * File "D:\py 2.7\Lib\site-packages\Selenium2Library\keywords__init_.py", line 3, in from _browsermanagement import _BrowserManagementKeywords File "D:\py 2.7\Lib\site-packages\Selenium2Library\keywords_browsermanagement.py", line 4, in from selenium import webdriver

@j1z0 - I installed Selenium2 library using the Windows installer "robotframework-selenium2library-1.0.0.win32.exe" and have imported the path to the test suite e.g. D:/py 2.7/Lib/site-packages/Selenium2Library

preshri avatar Mar 14 '12 09:03 preshri

the windows installer doesn't package all the dependencies.... we can look into it doing that... the best solution is pip install Selenium2Library. if you do that it will install all dependencies for you, including selenium, robot framework, decorator and whatever else.

j1z0 avatar Mar 14 '12 14:03 j1z0

preshri, so building off of j1z0 comments about the windows install vs. installing using "pip install Selenium2Library", you will need to also install the selenium package.

@j1z0,@rtomac, @myself - we might need to change the documentation so to reflect this more clearly. Also I thinking we might need a small pip/easy_install tutorial; like how to upgrade or pull a specific version.

emanlove avatar Mar 14 '12 14:03 emanlove

easy_install does not seem to work with 64 bit Python on Windows (http://pypi.python.org/pypi/setuptools), maybe that is the reason? - Herri

Concerning python's packaging tools there are two with very similar names, distutils and Distribute, but with different functionality. Distribute apparently is an upgrade and performs much better across platforms. There currently is an issue with installing robotframework on Linux using buildout (another "python-based configuration-driven build tool") which I am looking into and because it involves python packaging I will see about limitations for Win 64 bit.

emanlove avatar Mar 14 '12 14:03 emanlove

In case somebody else is wondering how to get started on Windows (64 bit or not), this is how I got things going:

  1. Install http://www.python.org/ftp/python/2.7.2/python-2.7.2.amd64.msi and set that installation directory to your Path env. variable
  2. Download http://peak.telecommunity.com/dist/ez_setup.py and run it.
  3. Execute easy_install robotframework-selenium2library
  4. Set [Python installation dir]\Lib and [Python installation dir]\Scripts to Path env. variable (not sure if this is even necessary, it used to be with RF and SeleniumLibrary)

Harri avatar Mar 14 '12 15:03 Harri

I followed Harri's steps on a 32-bit windows machine. It didn't fix the decorator module error for me, but easy_install (picked up in step 2) came in handy.

My steps and results:

  1. installed python-2.7.2 for 32 bit Windows XP
  2. downloaded and ran ez_setup.py

C:\qa_automation_git\pa2>python ez_setup.py Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-p y2.7.egg Processing setuptools-0.6c11-py2.7.egg Copying setuptools-0.6c11-py2.7.egg to c:\python27\lib\site-packages Adding setuptools 0.6c11 to easy-install.pth file Installing easy_install-script.py script to C:\Python27\Scripts Installing easy_install.exe script to C:\Python27\Scripts Installing easy_install.exe.manifest script to C:\Python27\Scripts Installing easy_install-2.7-script.py script to C:\Python27\Scripts Installing easy_install-2.7.exe script to C:\Python27\Scripts Installing easy_install-2.7.exe.manifest script to C:\Python27\Scripts

Installed c:\python27\lib\site-packages\setuptools-0.6c11-py2.7.egg Processing dependencies for setuptools==0.6c11 Finished processing dependencies for setuptools==0.6c11

  1. Execute easy_install C:>easy_install robotframework-selenium2library Processing robotframework-selenium2library Running rtomac-robotframework-selenium2library-893dc2c\setup.py -q bdist_egg --d ist-dir C:\robotframework-selenium2library\rtomac-robotframework-selenium2librar y-893dc2c\egg-dist-tmp-krzthy warning: no previously-included files found matching '_.rst' warning: no files found matching '.rst' under directory 'demo' warning: no files found matching '.sh' under directory 'demo' warning: no files found matching '.bat' under directory 'demo' warning: no files found matching '_.js' under directory 'demo' no previously-included directories found matching 'demo\reports' no previously-included directories found matching 'demo\selenium_log.txt' no previously-included directories found matching 'demo\output.xml' warning: no previously-included files matching '*.pyc' found under directory 'sr c' zip_safe flag not set; analyzing archive contents... ez_setup: module MAY be using inspect.getsourcefile Selenium2Library.init: module references file Selenium2Library.keywords._browsermanagement: module references file Adding robotframework-selenium2library 1.0.0 to easy-install.pth file

Installed c:\python27\lib\site-packages\robotframework_selenium2library-1.0.0-py 2.7.egg Processing dependencies for robotframework-selenium2library==1.0.0 Finished processing dependencies for robotframework-selenium2library==1.0.0

  1. Check my system PATH variable C:\qa_automation_git\pa2> echo %PATH% C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Python27;c:\Python27\Scripts;C:\RobotFramework\Python;C:\RobotFramework\Python\Scripts;

Run pybot on a simple test and it still failed with the decorator module error: C:\qa_automation_git\pa2>pybot my_login.txt [ ERROR ] Error in file 'C:\qa_automation_git\pa2\my_keywords.txt' in table 'Settings': Importing test library 'Selenium2Library' failed: ImportError: No m odule named decorator PYTHONPATH: ['C:\Python27\lib\site-packages\robot\libraries', 'C:\Python27 \lib\site-packages\setuptools-0.6c11-py2.7.egg', 'C:\Python27\lib\site-pac kages\robotframework_selenium2library-1.0.0-py2.7.egg', 'C:\WINDOWS\system32
\python27.zip', 'C:\Python27\DLLs', 'C:\Python27\lib', 'C:\Python27\lib\p lat-win', 'C:\Python27\lib\lib-tk', 'C:\Python27', 'C:\Python27\lib\site- packages', 'C:\Python27\lib\site-packages\win32', 'C:\Python27\lib\site-p ackages\win32\lib', 'C:\Python27\lib\site-packages\Pythonwin', '.'] Traceback (most recent call last): File "C:\Python27\lib\site-packages\robot\utils\importing.py", line 86, in no n_dotted_import module = import(name) File "C:\Python27\lib\site-packages\robotframework_selenium2library-1.0.0-py2. 7.egg\Selenium2Library__init_.py", line 2, in from keywords import * File "C:\Python27\lib\site-packages\robotframework_selenium2library-1.0.0-py2. 7.egg\Selenium2Library\keywords__init__.py", line 1, in from _logging import _LoggingKeywords File "C:\Python27\lib\site-packages\robotframework_selenium2library-1.0.0-py2. 7.egg\Selenium2Library\keywords_logging.py", line 5, in from keywordgroup import KeywordGroup File "C:\Python27\lib\site-packages\robotframework_selenium2library-1.0.0-py2. 7.egg\Selenium2Library\keywords\keywordgroup.py", line 4, in from decorator import decorator

In the end I fixed the dependencies by doing: easy_install decorator easy_install selenium

Now pybot runs as expected.

elizaleong avatar Mar 20 '12 03:03 elizaleong

this issue seems to be caused by an incorrect packaging: you have decorator and selenium listed as dependencies in your setup.py file but there is no requires.txt file inside the EGG-INFO directory of the distribution.

I strongly recommend you to use zest.releaser for this task.

hvelarde avatar Nov 27 '12 22:11 hvelarde

you may also take a look at your MANIFEST.in file: it's so complicated that it should be buggy...

hvelarde avatar Nov 28 '12 20:11 hvelarde

For completeness sake, I would like to add another use case.

I am using this pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.test</groupId>
    <artifactId>robotframeworktest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
<build>
    <plugins>
        <plugin>
            <groupId>org.robotframework</groupId>
            <artifactId>robotframework-maven-plugin</artifactId>
            <version>1.0.5</version>
            <executions>
                <execution>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Running mvn verify I get the exact same message ImportError: No module named decorator.

In this scenario it is not possible to install extra libraries as discussed above because the Maven plugin will use a prepackaged jython.jar.

Raptor399 avatar Dec 15 '12 08:12 Raptor399

Try installing decorator from https://pypi.python.org/pypi/decorator

saji-v avatar Sep 02 '15 06:09 saji-v

There has not been activity for this issue for few years and we are planning to close the old issues if they are not anymore valid ones. If you feel that this is still valid issue, could you send an update. If update is not received in a month, we will assume that this is not anymore an issues and we will close this issue.

aaltat avatar Nov 05 '15 19:11 aaltat

Closed because of inactivity. If someone encounters similar or same problem please open a new issue.

aaltat avatar Dec 10 '15 19:12 aaltat