ValueError: Invalid header value 'H2O Python client/2.7.9 (default, Apr 2 2015, 15:33:21) \n[GCC 4.9.2]'

自闭症网瘾萝莉.ら 提交于 2020-01-01 20:51:30

问题


I am trying to initialize H2O from Python. I am using python 2.7.9. I followed the steps below to get h2o python module:

pip install requests
pip install tabulate

# Remove any preexisiting H2O module.
pip uninstall h2o
# Next, use pip to install this version of the H2O Python module.
pip install http://h2o-release.s3.amazonaws.com/h2o-dev/master/1109/Python/h2o-0.3.0.1109-py2.py3-none-any.whl

I get this error when I call h2o.init().

No instance found at ip and port: localhost:54321. Trying to start local jar...

No jar file found. Could not start local instance.
Traceback (most recent call last):
File "abc.py", line 3, in <module>
h2o.init()
File "/usr/local/lib/python2.7/dist-packages/h2o/h2o.py", line 229, in init
H2OConnection(ip=ip, port=port)
File "/usr/local/lib/python2.7/dist-packages/h2o/connection.py", line 64, in __init__
cld = self._connect(size)
File "/usr/local/lib/python2.7/dist-packages/h2o/connection.py", line 113, in _connect
cld = H2OConnection.get_json(url_suffix="Cloud")
File "/usr/local/lib/python2.7/dist-packages/h2o/connection.py", line 324, in get_json
return __H2OCONN__._rest_json(url_suffix, "GET", None, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/h2o/connection.py", line 333, in _rest_json
raw_txt = self._do_raw_rest(url_suffix, method, file_upload_info, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/h2o/connection.py", line 366, in _do_raw_rest
http_result = self._attempt_rest(url, method, post_body, file_upload_info)
File "/usr/local/lib/python2.7/dist-packages/h2o/connection.py", line 394, in _attempt_rest
return requests.get(url, headers=headers)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 370, in send
timeout=timeout
File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 559, in urlopen
body=body, headers=headers)
File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 353, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python2.7/httplib.py", line 1048, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1087, in _send_request
self.putheader(hdr, value)
File "/usr/lib/python2.7/httplib.py", line 1026, in putheader
raise ValueError('Invalid header value %r' % (one_value,))
ValueError: Invalid header value 'H2O Python client/2.7.9 (default, Apr  2 2015, 15:33:21) \n[GCC 4.9.2]'

Please help me. Thanks in advance.


回答1:


Thanks Spencer Aiello for helping to fix the problem. I was using an older version of H2O. Now I got the latest version of H2O using:

pip install http://h2o-release.s3.amazonaws.com/h2o/rel-slater/9/Python/h2o-3.2.0.9-py2.py3-none-any.whl

It fixed the error.



来源:https://stackoverflow.com/questions/33345675/valueerror-invalid-header-value-h2o-python-client-2-7-9-default-apr-2-2015

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!