문제

I am on a Windows 7 64bit machine, using Python 2.7 and I am trying to use the python database library in robotframework. I have previously used a java library file but now I want to use the python library.

I have gone to github and downloaded version 0.6.

I have also installed a setup file and MySQL-python from here

However when I try to install the database library (using python setup.py build) I get the following error:

Traceback (most recent call last):
  File "setup.py", line 25, in <module>
    from DatabaseLibrary import __version__
  File "src\DatabaseLibrary\__init__.py", line 15, in <module>
    from connection_manager import ConnectionManager
  File "src\DatabaseLibrary\connection_manager.py", line 16, in <module>
    from robot.api import logger
ImportError: No module named api

Why do I not have robot.api and how do I get it and install it? Or is there an easier way to install the python database library?

도움이 되었습니까?

해결책

It seems that the Database library uses Robot Framework internals, but does not list Robot Framework as it's dependency. The robot.api package was introduced in RF 2.6, so upgrading/installing the latest Robot Framework (from project pages) should resolve your issue

다른 팁

First ensure the integrity of your module before trying to install. In order to install a module using distutils (setup.py) you need to run this command as an administrator:

python setup.py install

That should run the setup and report back to you any missing dependencies.

Alternatively, you can install PIP from this location: PIP Project home page. Their page provides instructions how to install PIP, it's a package manager for Python, similar to PEAR for PHP, CPAN for Perl or gem for ruby. When you have it installed you can install packages with this command:

pip install <module>

The issue was I did not have the "API" folder in the "Robot" folder in "Python27\Lib\site-packages" as I did not have the latest version of RF. And logger is a new logging API for Robot Framework 2.6 since Oct 2011. (As janne as pointed out)

Two fixes for this issue seem to be:

  1. Tested and worked but not recommended unless you dont want to update RF: Edit the 2 files "connection_manager.py" and "query.py" in "robotframework-databaselibrary-0.6" so that there is no dependency on the Robotframework logger. This is a easy and quick edit, where you replace the "from robot.api import logger" to "import logging" and "logger" to "logging" See "http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html#programmatic-logging-apis" for more detail.

  2. Reinstall Robotframework and ensure the "API" folder is created. This is recommended as it is the best approach.

(Added as an answer as too long for a comment)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top