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.)
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?
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')
print r.status_code
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?
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
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?