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?
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?
just tried it in the WIP - no luck.
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.
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:
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:
r = requests.get('http://www.google.com')
Am I missing something?
I guess I am missing something …
I just installed the new IP 2.7.5 then ran
ipy -X:Frames -m ensurepip
ipy -X:Frames -m pip install requests
And I could get it to work from the command line.
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?
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.”
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
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が使いたい/
But it is not ok too . so I have to give up !
Sorry for digging this old thing up, I might be having a similar issue.
I’m trying to load a Airtable API wrapper module in python, but get this error code:
cannot import idna from encodings:
Is this an incompatibility with IronPython, or is this something else?
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:
and the source code if you’re interested is here:
Super cool, I’ll check this out. Thanks !
I am having a similar problem, but it could be because I do not manage to install request in Iron Python.
How can I install requests in IronPython?
You might look into using .NET classes, such as HttpClient and WebRequest.