Importing library 'SeleniumLibrary' failed: ModuleNotFoundError: No module named 'SeleniumLibrary'

2,342 views
Skip to first unread message

Gerhard Heil

unread,
Jan 21, 2023, 1:45:53 PM1/21/23
to robotframework-users
Hi all,
I have installed robot framework selenium library via pip install. pip list outputs:
robotframework-seleniumlibrary 6.0.0

I have a testcase using selenium library; that works fine if I run it out of RIDE: no error message, all selenium keywords are executed as expected.

If I run the test from command prompt, selenium libaray is not found; I get the error message:
 Importing library 'SeleniumLibrary' failed: ModuleNotFoundError: No module named 'SeleniumLibrary'

Keywords from other libraries can be executed, when the test is called from command line. I have Robot Framework 5.0 with Python 3.8.0 on Windows 10. What is missing to get Selenium callable in command prompt environment?

Thanks and best regards
Gerhard

Hélio Guilherme

unread,
Jan 21, 2023, 2:08:13 PM1/21/23
to robotframework-users
Your problem is related to PATH or PYTHONPATH  settings.
Several hypotheses and combinations are possible:
  • RIDE has PYTHONPATH set correctly to find SeleniumLibrary
  • RIDE is using a different robot caller, than the one from command line (the run profile in RIDE, maybe is running robot.bat)
  • There are different Python installations, with different libraries installed (your pip command is not showing the libs for the actual execution)
Checks, you can do:
  • On RIDE see Tools->View RIDE Log, (paste here the top lines) 
  • See if different outputs in command line:
    • pip show SeleniumLibrary
    • <path_to_python.exe>\python -m pip show SeleniumLibrary
    • robot --version
    • <path_to_python.exe>\python -m robot --version

On Sat, Jan 21, 2023 at 6:45 PM Gerhard Heil <bloek...@gmail.com> wrote:
Hi all,
... 

Gerhard Heil

unread,
Jan 24, 2023, 2:22:40 PM1/24/23
to robotframework-users
Yes, I already expected some problem with %PATH% or %PYTHONPATH%. But even your check commands dont help me:

Tools->View RIDE Log outputs only two lines:
20230120 22:36:27.579 [INFO]: Found Robot Framework version 5.0 from C:\Users\Gerhard\AppData\Local\Programs\Python\Python38\lib\site-packages\robot.

20230120 22:36:27.580 [INFO]: Started RIDE v2.0b2.dev3 using python version 3.8.0 with wx version 4.0.7.post2 in win32.

An extract of pip list:
C:\Users\Gerhard\AppData\Local\Programs\Python\Python38>pip list
Package                        Version
------------------------------ -----------
robotframework                 5.0.1
robotframework-pythonlibcore   3.0.0
robotframework-seleniumlibrary 6.0.0
selenium                       4.2.0

The others output:
C:\Users\Gerhard\AppData\Local\Programs\Python\Python38>pip show SeleniumLibrary
WARNING: Package(s) not found: SeleniumLibrary

C:\Users\Gerhard\AppData\Local\Programs\Python\Python38>python -m pip show SeleniumLibrary
WARNING: Package(s) not found: SeleniumLibrary

C:\Users\Gerhard\AppData\Local\Programs\Python\Python38>robot --version
Robot Framework 5.0 (Python 3.8.0 on win32)

C:\Users\Gerhard\AppData\Local\Programs\Python\Python38>python -m robot --version
Robot Framework 5.0 (Python 3.8.0 on win32)

I assume that I have to set the path of SeleniumLibrary to %PATH% or to %PYTHONPATH%, but I don´t find the SeleniumLibrary.py anywhere on my system.
In C:\Users\Gerhard\AppData\Local\Programs\Python\Python38\lib\site-packages\robot\libraries there are  *.py files of the other libraries that I use, but I can´t find SeleniumLibrary file anywhere.

Hélio Guilherme

unread,
Jan 24, 2023, 3:36:36 PM1/24/23
to robotframework-users
Well, you don't have SeleniumLibrary installed. That is why it does not find it ;).


I assume that I have to set the path of SeleniumLibrary to %PATH% or to %PYTHONPATH%, but I don´t find the SeleniumLibrary.py anywhere on my system.
In C:\Users\Gerhard\AppData\Local\Programs\Python\Python38\lib\site-packages\robot\libraries there are  *.py files of the other libraries that I use, but I can´t find SeleniumLibrary file anywhere.

You need to install with:
pip install -U --force robotframework-seleniumlibrary

Note: I added the --force option to really make sure it downloads the newest package.

Also , you can upgrade robotframework to 6.0.2.
pip install -U robotframework


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/90e624f8-04b7-4896-bc2d-487e645fac50n%40googlegroups.com.

Gerhard Heil

unread,
Jan 27, 2023, 2:00:12 PM1/27/23
to robotframework-users
I tried this. It performs a long list of operations, collecting ... and moving files. Finally it outputs:
ERROR: Could not install packages due to an OSError: [WinError 2] Das System kann die angegebene Datei nicht finden: 'C:\\Python310\\Scripts\\libdoc.exe' -> 'C:\\Python310\\Scripts\\libdoc.exe.deleteme'

The red sentence is in English: The system cannot find the specified file.

Upgrading to robotframework 6.0.2 is done, but does not affect solving the selenium problem.

Hélio Guilherme

unread,
Jan 27, 2023, 2:47:29 PM1/27/23
to robotframework-users

I assume the file  'C:\\Python310\\Scripts\\libdoc.exe' -> 'C:\\Python310\\Scripts\\libdoc.exe.deleteme'
Existed in your system when upgrading packages and it was locked, therefore the renaming to the extension .deleteme.

I would restart the PC, to make sure there are not apps running and locking.
Then analyse if SeleniumLibrary is installed.
Also would try to uninstall robotframework, and install SeleniumLibrary with the force command (it will install robotframework too)

pip install -U --force robotframework-seleniumlibrary


Reply all
Reply to author
Forward
0 new messages