Rohan Thakur
Rohan Thakur

Reputation: 31

Importing library 'SeleniumLibrary' failed: ModuleNotFoundError: No module named 'SeleniumLibrary' In VS Code

Issue is recurring in VS Code

Error in file 'd:File Location' on line 2: Importing library 'SeleniumLibrary' failed: ModuleNotFoundError: No module named 'SeleniumLibrary'
Traceback (most recent call last):
  None
PYTHONPATH:
  c:\Users\Username\.vscode\extensions\robocorp.robotframework-lsp-0.35.0\src\robotframework_debug_adapter
  D:\Vector.ai\qa-automation-ui
  c:\Users\Username\.vscode\extensions\robocorp.robotframework-lsp-0.35.0\src
  c:\Users\Username\.vscode\extensions\robocorp.robotframework-lsp-0.35.0\src\robotframework_ls\vendored
  C:\Users\Username\AppData\Local\robocorp\holotree\b1f3c244e_9679c063\python38.zip
  C:\Users\Username\AppData\Local\robocorp\holotree\b1f3c244e_9679c063\DLLs
  C:\Users\Username\AppData\Local\robocorp\holotree\b1f3c244e_9679c063\lib
  C:\Users\Username\AppData\Local\robocorp\holotree\b1f3c244e_9679c063
  C:\Users\Username\AppData\Local\robocorp\holotree\b1f3c244e_9679c063\lib\site-packages
[ ERROR ] Error in file 'd:\Vector.ai\qa-automation-ui\KeyWords.robot' on line 2: Importing library 'SeleniumLibrary' failed: ModuleNotFoundError: No module named 'SeleniumLibrary'
Traceback (most recent call last):
  None
PYTHONPATH:
  c:\Users\Username\.vscode\extensions\robocorp.robotframework-lsp-0.35.0\src\robotframework_debug_adapter
  D:\Vector.ai\qa-automation-ui
  c:\Users\Username\.vscode\extensions\robocorp.robotframework-lsp-0.35.0\src
  c:\Users\Username\.vscode\extensions\robocorp.robotframework-lsp-0.35.0\src\robotframework_ls\vendored
  C:\Users\Username\AppData\Local\robocorp\holotree\b1f3c244e_9679c063\python38.zip
  C:\Users\Username\AppData\Local\robocorp\holotree\b1f3c244e_9679c063\DLLs
  C:\Users\Username\AppData\Local\robocorp\holotree\b1f3c244e_9679c063\lib
  C:\Users\Username\AppData\Local\robocorp\holotree\b1f3c244e_9679c063
  C:\Users\Username\AppData\Local\robocorp\holotree\b1f3c244e_9679c063\lib\site-packages

Upvotes: 3

Views: 19049

Answers (7)

Zakiy
Zakiy

Reputation: 21

I have uninstall and install again of RoboCorp, then the problem has been resolved.

Upvotes: 0

Kaushalya
Kaushalya

Reputation: 1

I faced the same issue and after disabling the robocorp extension, everything started working smoothly.

Upvotes: 0

Pauline-momanyi
Pauline-momanyi

Reputation: 1

Faced the same issue for both selenium library and appium library. The solution for me was to disable the robocorp extension and reload the window, and everything worked fine.

Upvotes: 0

Cabral
Cabral

Reputation: 21

I had the same problem, only using VS Code developing for RobotFramework and it presented the message

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

The solution was to disable the Robocorp Code plugin which stopped the error.

Upvotes: -1

Mohammad Amir
Mohammad Amir

Reputation: 63

First should be run this command in the command prompt to install the seleniumlibrary in the system:

pip install robotframework-seleniumlibrary

Then, you need to configure your Robocorp Code and Robot Framework Language Server extensions Python path in your Visual Studio Code then restart the Visual Studio Code and then execute your program.

Please refer to the official documentation: https://pypi.org/project/robotframework-seleniumlibrary

Upvotes: 5

Simon Nehez
Simon Nehez

Reputation: 1

You can see in the error message, that robocorp extension is using its own python instance and so it is using packages from C:\Users\Username\AppData\Local\robocorp\holotree\b1f3c244e_9679c063\lib\site-packages where seleniumlibrary is not installed.

You need to configure your Robocorp Code and Robot Framework Language Server extensions python path. When you do that, your extensions will be able to see packages (including selenium library) you installed to your python instance. You can configure your extensions in VS Code settings.

Upvotes: 0

Rajesh Nalluri
Rajesh Nalluri

Reputation: 1

I faced same issue in vscode with robocorp extensions. This fixed the issue for me: In vscode command palette (ctrl+shift+p), search for "Robocorp: Create Robot" and created a "standard Robot Framework Template". Now try running tests with Robocorp extension.

Upvotes: 0

Related Questions