The modules imported in variable file (.py) is not found by Robot framework when imported as Variable

I am planning to use the .py variable file to store my locators.
I would like to retrieve these locators dynamically by identifying a key mentioned in other .py file (config_variables) which is placed in the same root structure but in different folder.
Hence, I imported the config_variables.py in locators.py and was planning to leverage get_variables function to include the merge/filter logic based on the key from config_variables.

When I import this locators.py variable file as Variables in the Resource File, it throws an error stating the “Module Not Found” which was imported in the locators.py file.

I don’t see any error in locators.py but Robot throws the error. What’s the reason for this and how can we solve this issue?

Please help. Thanks!
Bheem

Your other Python file is most likely not in the PATH. If you have Python resources that are outside the venv and that are not the cwd, you’ll either to add them to the PythonPath (using the -P option) or turn your Python files into a (local) module.

Import order can cause this. if config_variables.py is imported late than locators.py. There’s also other things that could play a role here but the main thing is, without actually seeing your python code and example of how you import stuff into robot, nobody can’t give you a proper answer, just guess what could be going on.