I am making some sub-libraries(each as a module(a directory) with two files:- function file(.py) and init.py file) which I can use into the main library functions which will be used into the keyword file (List_of_keywords.resources). Now inside the python project the directories are as below order,
First I am using the Model1_Function file’s functions inside the New_robot_library.py file.
when I am trying to import the New_robot_library.py in List_of_keywords.resources file it is showing that
the ModuleNotFoundError error like below and the color is also not changing like in case of “Library
You can see the folder structure here in above picture and the three files as well.
So, do anyone have any idea what should I do here ?
You have to add root of the project (
NewProject) to PYTHONPATH. If you are using “Robot Framework Language Server” extension add to settings:
To robot parameters while executing add
-P . (assuming that your execution directory is root of the project).
I don’t get it. Can you tell me exactly in which file should I write this ?
Can you please specify how and where should i write the code which gave me ?
Can you please show me with screenshot, how and where should write the code ?
I would suggest making your libraries actual (local) distributions / packages so they get installed in your Python environment (hopefully a virtual environment) like all other dependencies. If you do that, you won’t have to use hacks to make the language servers work correctly and things will work on pipelines / other machines as well. I made a repo to demonstrate this:
GitHub - robinmackaij/robotframework-poetry-demo: A package to demonstrate how poetry can be used to distribute Robot Framework resources within an organization
I also did a talk at RoboCon on the topic:
RoboCon 2022 - 1.08 Project and package management: Poetry for robots - YouTube