Unable to import Requests Library in Robot Framework. Always getting error when trying to import the requests library. Can anyone please provide solution to import the library? Please find the software version details below.
Yes, I am using as you mentioned. But the library is not getting imported. It is always displaying in Red color. Upon right clicking it is showing Edit, Move Up, Move Down, Delete and Import Library Spec XML options.
It may take some time to get the keywords Documentation in RIDE.
If the library actually failed to import, you see errors logged in Tools->View RIDE Log.
Verified the logs from Tools → View Ride Log. Getting below error message. Could you please help?
Traceback (most recent call last):
Importing test library ‘RequestsLibrary’ failed: SyntaxError: invalid syntax (core.py, line 17)
Traceback (most recent call last):
File “C:\Python27\lib\site-packages\robotide\lib\robot\utils\importer.py”, line 143, in import
return__import_ (name, fromlist= fromlist)
File “C:\Python27\lib\site-packages\RequestsLibrary_init_.py”, line 1, in
from .DeprecatedKeywords import DeprecatedKeywords
File “C:\Python27\lib\site-packages\RequestsLibrary\DeprecatedKeywords.py”, line 6, in
from RequestsLibrary import utils
File “C:\Python27\lib\site-packages\RequestsLibrary\utils.py”, line 5, in
from requests.status_codes import codes
File “C:\Python27\lib\site-packages\requests-2.24.0-py2.7.egg\requests\ __ init__.py”, line 120, in
from . import utils
File “C:\Python27\lib\site-packages\requests-2.24.0-py2.7.egg\requests\utils.py”, line 25, in
from . import certs
File “C:\Python27\lib\site-packages\requests-2.24.0-py2.7.egg\requests\certs.py”, line 15, in
from certifi import where
File “C:\Python27\lib\site-packages\certifi-2023.07.22-py2.7.egg\certifi__init__py”, line 1, in
from .core import contents, where
Just be aware that Python 2.x has been End of Life for 3 years now, so more and more libraries will not work with Python 2 as time progresses. As you are using a non supported version of Python it will be very difficult for anyone to help you.
Not sure what your organisations justification for staying on Python 2 is, but the sooner you move to a supported Python version the easier your life will be, at this point you’ve had 15 years (EOL was announced in 2008) to move to python 3.x.
Perhaps your best bet for now would be to find out what the last version of requests that was supported on Python 2 was and downgrade to that version of requests, not sure if that will fix your issue or not but worth a try.
I haven’t used Python 2 for about 4-5 years, sorry I can’t be more help than that.