1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Error generating libspec: When trying to Import python libraries into Robot Framework...

Discussão em 'Python' iniciado por Stack, Setembro 14, 2024.

  1. Stack

    Stack Membro Participativo

    IDE: VSCode
    Python 3.10 + RobotFramework 5.0.1
    vscode extension: Robot Framework Language server 0.47.2


    Folder structure:

    [​IMG]

    In libraries.resource file i am calling the dbutils library as:

    Libraries ./libraries/Utilities/utils.py


    In my utils.py file, i am importing the file dbutils.py as:

    from libraries.DBUtilities.dbutils import dbutils

    class utils():
    def __init__(self):
    self.ut = dbutils()


    With this setup, the robotframework language server throws the error as below:

    Unresolved library: ../libraries/Utilities/utils.py
    Error generating libspec:
    Importing library 'utils' failed: ModuleNotFoundError: No module named 'utils'
    Consider adding the needed paths to the "robot.pythonpath" setting
    and calling the "Robot Framework: Clear caches and restart" action.robotframework


    I have tried,


    • use Import instead of from


    • use try: and except:


    • added the libraries into the vscode workspace file under "robot.pythonpath" section


    • applied "Robot Framework: Clear caches and restart" from the vscode command pallete

    Edit 1:

    project workspace file has the following settings:

    "robot.pythonpath": ["${workspaceFolder}/.venv/Scripts/python.exe", "${workspaceFolder}/libraries"],
    "robot.language-server.python": "${workspaceFolder}/.venv/Scripts/python.exe",
    "robot.python.executable": "${workspaceFolder}/.venv/Scripts/python.exe",

    Continue reading...

Compartilhe esta Página