问题描述
我已经在ironpython上成功安装了pip.但是,当我尝试在管理员控制台中使用"ipy.exe -X:Frames -m pip安装请求"安装请求时,会得到以下信息:
I've successful installed pip on ironpython. But when i try to install requests with "ipy.exe -X:Frames -m pip install requests" in a administrator console I get the following:
------------------------------------------------------------
C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\__main__.py run on 02/02/16 16:13:53
Downloading/unpacking html5lib
Getting page https://pypi.python.org/simple/html5lib/
Cleaning up...
Removing temporary dir c:\users\panta\appdata\local\temp\pip_build_panta...
Exception:
Traceback (most recent call last):
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\commands\install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\req.py", line 1183, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\index.py", line 194, in find_requirement
page = self._get_page(main_index_url, req)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\index.py", line 566, in _get_page
return HTMLPage.get_page(link, req,
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\index.py", line 670, in get_page
resp = session.get(url, headers={"Accept": "text/html"})
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\_vendor\requests\sessions.py", line 468, in get
return self.request('GET', url, **kwargs)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\download.py", line 237, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\_vendor\requests\sessions.py", line 456, in request
resp = self.send(prep, **send_kwargs)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\_vendor\requests\sessions.py", line 559, in send
r = adapter.send(request, **kwargs)
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\_vendor\requests\adapters.py", line 317, in send
resp = conn.urlopen(
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 491, in urlopen
httplib_response = self._make_request(conn, method, url,
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 291, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Program Files (x86)\IronPython 2.7\Lib\httplib.py", line 955, in request
self._send_request(method, url, body, headers)
File "C:\Program Files (x86)\IronPython 2.7\Lib\httplib.py", line 989, in _send_request
self.endheaders(body)
File "C:\Program Files (x86)\IronPython 2.7\Lib\httplib.py", line 951, in endheaders
self._send_output(message_body)
File "C:\Program Files (x86)\IronPython 2.7\Lib\httplib.py", line 811, in _send_output
self.send(msg)
File "C:\Program Files (x86)\IronPython 2.7\Lib\httplib.py", line 773, in send
self.connect()
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\_vendor\requests\packages\urllib3\connection.py", line 197, in connect
match_hostname(self.sock.getpeercert(),
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\_vendor\requests\packages\urllib3\packages\ssl_match_hostname\_implementation.py", line 88, in match_hostname
for key, value in sub:
ValueError: too many values to unpack
那么,现在有一些方法可以在ironpython上安装支持pip的请求?我尝试使用(在管理员控制台中):
So, there is some way to install requests on ironpython now that supports pip? I tried using (in administrator console):
- ipy.exe -X:Frames -m pip安装请求
- ipy.exe -X:FullFrames -m pip安装请求
- ipy.exe -m pip安装请求
- ipy.exe -X:Frames Scripts \ pip2.7.exe安装请求
- ipy.exe -X:FullFrames脚本\ pip2.7.exe安装请求
- ipy.exe -X:FullFrames脚本\ pip2.exe安装请求
- ipy.exe -X:FullFrames脚本\ easy_install-2.7.exe请求
当我尝试"ipy.exe -X:FullFrames -m easy_install请求"时,我得到:
An when i try "ipy.exe -X:FullFrames -m easy_install requests" i get:
C:\Program Files (x86)\IronPython 2.7\Lib\weakref.py:1: DeprecationWarning: object.__init__() takes no parameters for type KeyedRef
"""Weak reference support for Python.
Searching for requests
Reading https://pypi.python.org/simple/requests/
Best match: requests 2.9.1
Downloading https://pypi.python.org/packages/source/r/requests/requests-2.9.1.tar.gz#md5=0b7f480d19012ec52bab78292efd976d
Processing requests-2.9.1.tar.gz
Writing c:\users\panta\appdata\local\temp\easy_install-mbdcgv\requests-2.9.1\setup.cfg
Running requests-2.9.1\setup.py -q bdist_egg --dist-dir c:\users\panta\appdata\local\temp\easy_install-mbdcgv\requests-2.9.1\egg-dist-tmp-rzrv6w
warning: build_py: byte-compiling is disabled, skipping.
warning: install_lib: byte-compiling is disabled, skipping.
warning: easy_install: byte-compiling is disabled, skipping.
它使用setup.py创建文件夹C:\ Users \ panta \ AppData \ Local \ Temp \ easy_install-mbdcgv \ requests-2.9.1,但是当我尝试运行时,出现错误没有提供命令".那么,有一种方法可以在ironpython 2.7.5上导入请求吗?
An it creates the folder C:\Users\panta\AppData\Local\Temp\easy_install-mbdcgv\requests-2.9.1 with a setup.py but when I try to run, it gives an error "No commands supplied".So, there is a way to import requests on ironpython 2.7.5?
现在,使用easy_install可以运行",但是当我尝试导入请求"时,我收到以下信息:
Now with easy_install it "worked" but when i try to "import requests" i receive the following:
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\requests-2.9.1-py2.7.egg\requests\__init__.py", line 53, in <module>
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\requests-2.9.1-py2.7.egg\requests\packages\__init__.py", line 27, in <module>
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\requests-2.9.1-py2.7.egg\requests\packages\urllib3\__init__.py", line 8, in <module>
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\requests-2.9.1-py2.7.egg\requests\packages\urllib3\connectionpool.py", line 34, in <module>
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\requests-2.9.1-py2.7.egg\requests\packages\urllib3\packages\six.py", line 330, in <module>
File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\requests-2.9.1-py2.7.egg\requests\packages\urllib3\packages\six.py", line 320, in exec_
AttributeError: 'module' object has no attribute '_getframe'
那么,是否没有IronPython的请求模块?
So, no requests module for ironpython?
推荐答案
不幸的是,urllib3
使用的six
库(又由requests
使用)与IronPython不兼容.请参阅问题135 six
项目跟踪器,可能有解决方法.
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.
显然,这是IronPython兼容的唯一方法,请参阅requests问题跟踪器中的问题#2324 .
Apparently, that's the only thing standing in the way of IronPython-compatibility, see issue #2324 in the requests
issue tracker.
您可以通过在six
模块中用直接调用exec()
的方式替换exec_()
的定义来使其工作. urllib3
实际上实际上并没有使用任何对six.exec_()
的调用,并且exec()
在Python 2代码中工作得很好.
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.
这篇关于是否可以在ironpython 2.7.5中使用请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!