# Unable to import Request Library in Robot Framework

**URL:** https://forum.robotframework.org/t/unable-to-import-request-library-in-robot-framework/6587
**Category:** Libraries
**Created:** [23 December 2023 20:25 UTC](https://forum.robotframework.org/t/unable-to-import-request-library-in-robot-framework/6587 "2023-12-23T20:25:46Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![raagul](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@raagul](https://forum.robotframework.org/u/raagul)
#### Post date: [23 December 2023 20:25 UTC](https://forum.robotframework.org/t/unable-to-import-request-library-in-robot-framework/6587/1 "2023-12-23T20:25:46Z")

</div>

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.

Python=2.7.9  
requests=2.24.0  
robotframework=3.0  
robotframework-requests=0.9.6  
robotframework-ride=1.5.2.1

---

<div class="post-metadata">

### Author: ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)
#### Post date: [23 December 2023 23:37 UTC](https://forum.robotframework.org/t/unable-to-import-request-library-in-robot-framework/6587/2 "2023-12-23T23:37:44Z")

</div>

Hi Raagul,

All I’ve ever needed to do is put this in the beginning of my robot file:

```python
***Settings***
Library RequestsLibrary

```

After that just use the Requests Library keywords in my test cases.

Is that what you’re doing? what errors are you getting?

Dave.

---

<div class="post-metadata">

### Author: ![raagul](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@raagul](https://forum.robotframework.org/u/raagul)
#### Post date: [24 December 2023 12:55 UTC](https://forum.robotframework.org/t/unable-to-import-request-library-in-robot-framework/6587/3 "2023-12-24T12:55:02Z")

</div>

Hi Dave,

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.

Raagul

---

<div class="post-metadata">

### Author: ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)
#### Post date: [24 December 2023 13:04 UTC](https://forum.robotframework.org/t/unable-to-import-request-library-in-robot-framework/6587/4 "2023-12-24T13:04:12Z")

</div>

Hi Raagul,

> [@raagul](#):
>
> It is always displaying in Red color.

That sound like an issue with your editor’s syntax highlighting system not robot framework.

Mention which editor you’re using and what robot framework related plugin you have and hopefully someone who’s familiar with them can help you.

Dave.

---

<div class="post-metadata">

### Author: ![raagul](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@raagul](https://forum.robotframework.org/u/raagul)
#### Post date: [24 December 2023 13:13 UTC](https://forum.robotframework.org/t/unable-to-import-request-library-in-robot-framework/6587/5 "2023-12-24T13:13:08Z")

</div>

Hi Dave,

I’m using RIDE. Able to use other libraries and keywords. Facing issue only with RequestsLibrary.

Thanks,  
Raagul

---

<div class="post-metadata">

### Author: ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)
#### Post date: [24 December 2023 14:31 UTC](https://forum.robotframework.org/t/unable-to-import-request-library-in-robot-framework/6587/6 "2023-12-24T14:31:22Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![raagul](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@raagul](https://forum.robotframework.org/u/raagul)
#### Post date: [24 December 2023 16:04 UTC](https://forum.robotframework.org/t/unable-to-import-request-library-in-robot-framework/6587/7 "2023-12-24T16:04:02Z")

</div>

Hi Helio Guiherme66,

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

Thanks,  
Raagul

---

<div class="post-metadata">

### Author: ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)
#### Post date: [24 December 2023 21:58 UTC](https://forum.robotframework.org/t/unable-to-import-request-library-in-robot-framework/6587/8 "2023-12-24T21:58:34Z")

</div>

Must you use Python 2.7?

You can try to re-install Requests.

```python
pip install --force --upgrade requests

```

---

<div class="post-metadata">

### Author: ![raagul](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@raagul](https://forum.robotframework.org/u/raagul)
#### Post date: [29 December 2023 06:54 UTC](https://forum.robotframework.org/t/unable-to-import-request-library-in-robot-framework/6587/9 "2023-12-29T06:54:56Z")

</div>

Yes, I must use Python 2.7.  
Upgrade requests to latest version is not working.

---

<div class="post-metadata">

### Author: ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)
#### Post date: [29 December 2023 08:00 UTC](https://forum.robotframework.org/t/unable-to-import-request-library-in-robot-framework/6587/10 "2023-12-29T08:00:57Z")

</div>

Hi Raagul,

> [@raagul](#):
>
> Yes, I must use Python 2.7.

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.

> **[Sunsetting Python 2](https://www.python.org/doc/sunset-python-2/)**
>
> The official home of the Python Programming Language

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.

Dave.
