It's possible to use requests in ironpython 2.7.5?

房东的猫 提交于 2019-12-06 09:52:28

Unfortunately, the six library used by urllib3 (in turn used by requests) is not compatible with IronPython. See issue 135 in the six project tracker, which may have a work-around.

Apparently, that's the only thing standing in the way of IronPython-compatibility, see issue #2324 in the requests issue tracker.

You probably could make it work by replacing the definition for exec_() with calls directly to exec(), in the six module. urllib3 doesn't actually use any calls to six.exec_() anyway, and exec() works just fine in Python 2 code.

I believe it works at least for trivial cases.

My exact install command is:

ipy.exe -X:Frames -m pip install --user requests

And the example session right after:

c:\cygwin64\home\rejap>ipy -X:Frames
IronPython 2.7.5 (2.7.5.0) on .NET 4.0.30319.42000 (32-bit)
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> r=requests.get('http://google.com')
C:\Users\rejap\AppData\Roaming\Python\IronPython27\site-packages\requests\packages\urllib3\connectionpool.py:1: DeprecationWarning: object.__new__() takes no parameters
from __future__ import absolute_import
>>> r
<Response [200]>
>>>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!