RobotFramework LSP for Pycharm is not taking into account Pythonpath settings during libspec creation step
See original GitHub issueDescription of the defect I’m using RoboFramework LSP for Pycharm and it’s failing during the libspec generation for my custom libraries. I have a directory structure as follows:
|-tests
|-resources
| |-my_first_module
| | |-FirstRobotCustomLib.py
| | |-SecondRobotCustomLib.py
| | |-...
| |-my_second_module
| | |-ThirdRobotCustomLib.py
| | |-...
| |...
|...
Inside the “resources” directory i have all the python modules that conform a set of customized robotframework libraries. As I don’t have these modules instaled, but they’re directly imported in the robot tests, I have update the Pythonpath setting for robotframework-lsp plugin as follows:

But, looking at the errors from robot_err log file it seems that this path is not applied:
lsp: 2021-04-16 17:02:43 UTC pid: 32689 - ThreadPoolExecutor-1_0 - EXCEPTION - robotframework_ls.impl.libspec_manager
Error creating libspec: AssetsApi.
Return code: 252
Output:
Importing test library 'AssetsApi' failed: ModuleNotFoundError: No module named 'resources'
Traceback (most recent call last):
File "/home/albertm/workspace/automated-tests-firedrill/resources/objects_layer/api/assets/AssetsApi.py", line 6, in <module>
from resources.objects_layer.api.AiqApi import AiqApi
PYTHONPATH:
/home/albertm/workspace/automated-tests-firedrill/resources/objects_layer/api/assets
/home/albertm/workspace/automated-tests-firedrill/resources/objects_layer/api/assets
/usr/lib/python38.zip
/usr/lib/python3.8
/usr/lib/python3.8/lib-dynload
/home/albertm/workspace/automated-tests-firedrill/venv/lib/python3.8/site-packages
Try --help for usage information.
To Reproduce Steps to reproduce the behavior:
- Open Pycharm
- Go to File -> Settings -> Languages & Frameworks -> Robot Framework (Project)
- Add the path to python executable for the used venv within the “Language Server Python” field.
- Add the path to the root python custom library module within the “Pythonpath” field usin with JSON array format.
- Apply the configuration and restart the IDE.
- Analyze the error logs from lsp/robot_err_<timestamp>.log
Expected Behavior During the libspec generation for the custom robot libraries, the directory added in the “Pythonpath” setting should be added to the Pythonpath in order to be able to find Python dependencies that are not installed as actual libraries in the Python environment.
Actual Behavior During the libspec generation the robot.libdoc process fails because no custom dependences are found in the Pythonpath. I’ve tried to execute the process manually adding the same directory configured in the “Pythonpath” settings for robotframework-lsp plugin using the robot.libdoc -P argument and its works correctly, so it seems that settings are not being correctly applied.
Versions:
- OS: Ubuntu 18.04
- Robot Framework 3.2.2
- Robot Framework Language Server 0.14.0
- Client PyCharm 2021.1 Professional Edition
Logs Full log file: robot_err_20210416.log
Issue Analytics
- State:
- Created 2 years ago
- Comments:6

Top Related StackOverflow Question
@fabioz After solving all the constructors, it works like a charm.
Thank you for helping me through these errors!
Humm, I’m taking a look at the logs here… it shows:
So, the
PYTHONPATHseems to be making it properly, but theBasicPageObjectconstructor is not ok.Also, there’s:
Where the default constructor is also not ok…
So, in this case, what needs to be done is fix those so that the libspec can be properly generated for them (reference: https://github.com/robocorp/robotframework-lsp/blob/master/robotframework-ls/docs/faq.md#how-to-proceed-if-keywords-from-a-library-are-not-being-resolved).
One thing that just occurred to me is that the language server caches that a library wasn’t generated and won’t try to recreate it until it’s restarted (due to performance considerations as attempting to generate a libspec can be slow), so, you have to fix the library and then use the
Reload Windowcommand so that the language server is restarted to retest…You can inspect the
robotframework_ls.log.lint.lsp.<pid>.api.logto check if there are further related errors.As the
PYTHONPATHis being properly set and the errors seem to be all on the library, I’m closing the issue, since I don’t think anything needs to be done in the language server.I created https://github.com/robocorp/robotframework-lsp/issues/324 so that in the future the language server makes the error more apparent.