# Import "requests" module in python

**URL:** <https://discourse.mcneel.com/t/import-requests-module-in-python/14822>\
**Category:** Scripting\
**Created:** [December 10, 2014, 6:22pm UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822 "2014-12-10T18:22:07Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![andheum](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/andheum/32/743341_2.png) [@andheum](https://discourse.mcneel.com/u/andheum)\
**Post date:** [December 10, 2014, 6:22pm UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/1 "2014-12-10T18:22:07Z")

</div>

I’m having trouble importing the “requests” module in the rhino python environment. It works just fine when I run ironpython directly - ipy.exe with frames enabled - but when I try “import requests” in a python script it tells me “No module named requests”. I have frames enabled in my rhino python editor, and I have both C:\Program Files (x86)\IronPython 2.7\Lib and C:\Program Files\Rhinoceros 5.0 (64-bit)\Plug-ins\IronPython\Lib in my module search paths. I even have identical \site-packages\requests-2.4.3-py2.7.egg directories in both of those places.

(on a side note, despite having both in the module search paths, I sometimes seem to be unable to load modules that are in the ironpython directory - only those that I’ve copied into the rhino plugin’s “Lib” folder.)

@stevebaer any thoughts?

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [December 10, 2014, 9:35pm UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/2 "2014-12-10T21:35:53Z")

</div>

Rhino ships with an older version of IronPython which may be what is causing the problem. Have you tried this with the WIP which uses a newer version of IronPython?

---

<div class="post-metadata">

**Author:** ![andheum](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/andheum/32/743341_2.png) [@andheum](https://discourse.mcneel.com/u/andheum)\
**Post date:** [December 10, 2014, 10:17pm UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/3 "2014-12-10T22:17:58Z")

</div>

just tried it in the WIP - no luck.

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [December 10, 2014, 10:34pm UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/4 "2014-12-10T22:34:21Z")

</div>

I logged this as a bug in our system since I’m not sure what is causing the problem and am stuck in the middle of a large project at the moment.  
[http://mcneel.myjetbrains.com/youtrack/issue/RH-29266](http://mcneel.myjetbrains.com/youtrack/issue/RH-29266)

---

<div class="post-metadata">

**Author:** ![Alain](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/alain/32/512812_2.png) [@Alain](https://discourse.mcneel.com/u/Alain)\
**Post date:** [December 11, 2014, 12:10pm UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/5 "2014-12-11T12:10:19Z")

</div>

Hi.

From what you wrote the last directory , “site-packages”, doesn’t seem to be on your path. I got it to load by adding it to the search paths or by importing it this way:

```auto
requests = __import__ ("site-packages/requests")

```

I used the \__import_\_ function because of the dash in the directory name.

I got it to load but this package seems to have native dependencies that won’t run in IronPython. I couldn’t get this to work:

```auto
r = requests.get('http://www.google.com')
print r.status_code

```

Am I missing something?

---

<div class="post-metadata">

**Author:** ![Alain](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/alain/32/512812_2.png) [@Alain](https://discourse.mcneel.com/u/Alain)\
**Post date:** [December 11, 2014, 12:25pm UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/6 "2014-12-11T12:25:02Z")

</div>

I guess I am missing something …

I just installed the new IP 2.7.5 then ran

```auto
ipy -X:Frames -m ensurepip
ipy -X:Frames -m pip install requests

```

And I could get it to work from the command line.

---

<div class="post-metadata">

**Author:** ![JimCarruthers](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jimcarruthers/32/504725_2.png) [@JimCarruthers](https://discourse.mcneel.com/u/JimCarruthers)\
**Post date:** [February 26, 2016, 6:12pm UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/7 "2016-02-26T18:12:46Z")

</div>

I was just trying to run a found script that uses requests and ran into this issue, I can’t find “ipy.exe” to actually install pip and requests, how do I do that? …Okay so that’s if I install IronPython separately…but can I then access that from Rhino?

Thanks,  
Jim

---

<div class="post-metadata">

**Author:** ![JimCarruthers](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jimcarruthers/32/504725_2.png) [@JimCarruthers](https://discourse.mcneel.com/u/JimCarruthers)\
**Post date:** [February 27, 2016, 3:16am UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/8 "2016-02-27T03:16:20Z")

</div>

So I installed Ironpython 2.7.5, and the WIP, installed requests, added the search paths in the Rhino Python editor, and…“no module named requests.”

---

<div class="post-metadata">

**Author:** ![Alain](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/alain/32/512812_2.png) [@Alain](https://discourse.mcneel.com/u/Alain)\
**Post date:** [February 29, 2016, 3:57pm UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/9 "2016-02-29T15:57:08Z")

</div>

Hi Jim,

Is the “request” directory part of your path? The last directory on the path should be the one that contains the “request” directory.

At the command line I can get a “requests.get(”…") to work but in Rhino even though I can is import the module I can’t do a “get”. I get an “unknown encoding: idna” msg which led me to find [this issue](https://github.com/shotgunsoftware/python-api/issues/72)

---

<div class="post-metadata">

**Author:** ![winsion](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/winsion/32/125436_2.png) [@winsion](https://discourse.mcneel.com/u/winsion)\
**Post date:** [May 31, 2016, 6:27am UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/10 "2016-05-31T06:27:19Z")

</div>

I got same error in Requests 2.1  
At last , I understand I work for nothing … I try to revise it as this post : [http://www.lancard.com/blog/2013/03/08/ironpythonでもrequestsが使いたい/](http://www.lancard.com/blog/2013/03/08/ironpython%E3%81%A7%E3%82%82requests%E3%81%8C%E4%BD%BF%E3%81%84%E3%81%9F%E3%81%84/)

But it is not ok too . so I have to give up !

---

<div class="post-metadata">

**Author:** ![rheinason](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/rheinason/32/758156_2.png) [@rheinason](https://discourse.mcneel.com/u/rheinason)\
**Post date:** [September 30, 2019, 12:27pm UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/11 "2019-09-30T12:27:09Z")

</div>

Hi there

Sorry for digging this old thing up, I might be having a similar issue.  
I’m trying to load a [Airtable API wrapper](https://airtable-python-wrapper.readthedocs.io/en/master/) module in python, but get this error code:  
cannot import idna from encodings:  
 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/d/6/d6510604c559c9bb908b29ebbfbe2b6b9a4e032a.png)

Is this an incompatibility with IronPython, or is this something else?

---

<div class="post-metadata">

**Author:** ![Nick\_Cassab](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nick_cassab/32/666659_2.png) [@Nick\_Cassab](https://discourse.mcneel.com/u/Nick_Cassab)\
**Post date:** [November 26, 2019, 8:59pm UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/12 "2019-11-26T20:59:06Z")

</div>

hi @rheinason,

I had similar issues when trying to load an airtable wrapper in csharp but managed to get it to work.

The GH plugin is here:

> **[Mallard](https://www.food4rhino.com/en/app/mallard)**
>
> UPDATED to 2.0 -- Mallard is a Plugin to connect Grasshopper to Airtable.

and the source code if you’re interested is here:

> **[GitHub - NickCassab/Mallard: A Grasshopper Plugin to connect Grasshopper (the...](https://github.com/NickCassab/Mallard)**
>
> A Grasshopper Plugin to connect Grasshopper (the visual programming tool built in to Rhino3D) to the easily editable database tool Airtable, based on the CSharp fork of the Airtable API by ngonicholas.

---

<div class="post-metadata">

**Author:** ![rheinason](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/rheinason/32/758156_2.png) [@rheinason](https://discourse.mcneel.com/u/rheinason)\
**Post date:** [November 27, 2019, 11:58am UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/13 "2019-11-27T11:58:42Z")

</div>

Hi @Nick_Cassab

Super cool, I’ll check this out. Thanks !

---

<div class="post-metadata">

**Author:** ![Erik\_Beeren](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/erik_beeren/32/770699_2.png) [@Erik\_Beeren](https://discourse.mcneel.com/u/Erik_Beeren)\
**Post date:** [May 25, 2022, 6:49am UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/14 "2022-05-25T06:49:23Z")

</div>

I am having a similar problem, but it could be because I do not manage to install request in Iron Python.

 ![afbeelding](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/e/4/f/e4fa968d84f8a89fe12d2bdb922beba082646291.png)

How can I install requests in IronPython?

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [May 25, 2022, 3:13pm UTC](https://discourse.mcneel.com/t/import-requests-module-in-python/14822/15 "2022-05-25T15:13:03Z")

</div>

Hi @Erik_Beeren,

You might look into using .NET classes, such as [HttpClient](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=netframework-4.8) and [WebRequest](https://docs.microsoft.com/en-us/dotnet/api/system.net.webrequest?view=netframework-4.8).

– Dale
