{"id":3263,"library":"robotframework-pythonlibcore","title":"Robot Framework PythonLibCore","description":"Robot Framework PythonLibCore (version 4.5.0) is a generic component designed to simplify the creation of larger, more flexible test libraries for Robot Framework using Python. It abstracts away the complexities of the Robot Framework's hybrid and dynamic library APIs, providing a streamlined interface. The library is actively maintained with frequent releases addressing bug fixes, performance enhancements, and compatibility with new Python and Robot Framework versions. It is widely used by other popular Robot Framework libraries like SeleniumLibrary and Browser library.","status":"active","version":"4.5.0","language":"en","source_language":"en","source_url":"https://github.com/robotframework/PythonLibCore","tags":["robot-framework","test-automation","library-development","python","keyword-driven"],"install":[{"cmd":"pip install robotframework-pythonlibcore","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core dependency for developing Robot Framework test libraries. Supports Robot Framework 6.1 and newer since version 4.5.0, and Robot Framework 7.0 since version 4.3.0.","package":"robotframework","optional":false},{"reason":"Direct dependency for backported and experimental type hints.","package":"typing-extensions","optional":false},{"reason":"Direct dependency for decorators, wrappers and monkey patching.","package":"wrapt","optional":false}],"imports":[{"symbol":"DynamicCore","correct":"from robotlibcore import DynamicCore"},{"symbol":"HybridCore","correct":"from robotlibcore import HybridCore"},{"note":"While `robot.api.deco.keyword` also exists, `robotlibcore.keyword` is the intended decorator when building libraries with PythonLibCore, as it integrates seamlessly with its internal mechanisms.","wrong":"from robot.api.deco import keyword","symbol":"keyword","correct":"from robotlibcore import keyword"}],"quickstart":{"code":"from robotlibcore import DynamicCore, keyword\n\nclass LibraryComponent1:\n    @keyword\n    def my_first_keyword(self, arg):\n        print(f\"Executing My First Keyword with: {arg}\")\n        return f\"Processed: {arg}\"\n\nclass LibraryComponent2:\n    @keyword('Custom Name Keyword')\n    def another_keyword(self, value):\n        print(f\"Executing Another Keyword with value: {value}\")\n        return f\"Custom handled: {value}\"\n\nclass MyLibrary(DynamicCore):\n    \"\"\"Example Robot Framework library using PythonLibCore.\"\"\"\n\n    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'\n\n    def __init__(self):\n        # Pass instances of classes containing keywords to DynamicCore\n        libraries = [LibraryComponent1(), LibraryComponent2()]\n        DynamicCore.__init__(self, libraries)\n\n    @keyword\n    def keyword_in_main_library(self, data):\n        \"\"\"A keyword directly in the main library class.\"\"\"\n        print(f\"Keyword in main library received: {data}\")\n        return data.upper()\n\n# To use this library in Robot Framework:\n# *** Settings ***\n# Library    MyLibrary.py\n#\n# *** Test Cases ***\n# Example Test\n#     ${result1}=    My First Keyword    hello\n#     Log To Console    ${result1}\n#     ${result2}=    Custom Name Keyword    world\n#     Log To Console    ${result2}\n#     ${result3}=    Keyword In Main Library    pythonlibcore\n#     Log To Console    ${result3}","lang":"python","description":"This example demonstrates creating a Robot Framework test library using `DynamicCore` from `robotlibcore`. It defines two separate classes (`LibraryComponent1`, `LibraryComponent2`) that contain keywords, decorated with `@keyword`. These components are then passed to the `DynamicCore`'s constructor in the main `MyLibrary` class. It also shows a keyword directly implemented in the main library class."},"warnings":[{"fix":"Upgrade to Python 3.8 or newer, or pin `robotframework-pythonlibcore` to `<4.2.0`.","message":"Python 3.7 support was dropped in PythonLibCore v4.2.0. Users on Python 3.7 must either upgrade their Python version or use an older version of `robotframework-pythonlibcore`.","severity":"breaking","affected_versions":">=4.2.0"},{"fix":"Always check the release notes for `robotframework-pythonlibcore` to ensure compatibility with your Robot Framework version. Upgrade or downgrade `robotframework-pythonlibcore` as needed.","message":"Major Robot Framework versions require specific `pythonlibcore` compatibility. For instance, v3.0.0 dropped support for Robot Framework 3.1 and addressed issues with Robot Framework 4 and `typing.Union`. Version 4.3.0 added support for Robot Framework 7.0, and v4.5.0 supports Robot Framework 6.1 and newer.","severity":"breaking","affected_versions":"All versions"},{"fix":"Upgrade to `robotframework-pythonlibcore` version 4.4.1 or newer to avoid this issue.","message":"Prior to v4.4.1, a bug could cause custom keyword names defined via the `@keyword` decorator to 'leak', potentially leading to unexpected keyword resolution or conflicts.","severity":"gotcha","affected_versions":"<4.4.1"},{"fix":"If your library is in `mylibrary.py` and the class is `MyLibrary`, import it as `Library    mylibrary.MyLibrary` or ensure `mylibrary.py` is directly in the Python module search path and can be imported as `Library    mylibrary` (where the module's `__init__.py` or the module itself exposes `MyLibrary`).","message":"Incorrect library import paths in Robot Framework are a common source of 'No keyword with name X found' errors. When importing a Python class-based library, ensure the import path correctly points to the module or class.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Let `DynamicCore` handle keyword discovery by decorating methods with `@keyword` and passing component instances to `DynamicCore.__init__`.","message":"When developing a dynamic library with PythonLibCore, prefer inheriting `DynamicCore` (or `HybridCore`) and using the `@keyword` decorator on methods within your component classes. Avoid manually implementing `get_keyword_names()` and `run_keyword()` if you are using PythonLibCore's keyword discovery mechanism, as this can lead to keywords not being registered or found.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `robotframework-pythonlibcore` version 4.5.0 or newer.","message":"Version 4.5.0 includes a bug fix to avoid 'maximum recursion depth exceeded' errors on `getattr`. If you encounter this error in older versions, it might be related to this known issue.","severity":"gotcha","affected_versions":"<4.5.0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}