PyArango.Connection 失败 json.decoder.JSONDecodeError 未被用户代码处理

PyArango.Connection Fails with json.decoder.JSONDecodeError was unhandled by user code

我正在尝试为 ArangoDB 使用 PyArango 驱动程序。我正在为 Windows 使用 Python 3.5.2(这是我的组织提供的)和 ArangoDB 3.0 运行 在我的计算机上本地使用。

我运行在python交互shell(或脚本)中的以下内容:

from pyArango.connection import *
myConnection = Connection()

当对 Connection() 行求值时,以下输出到控制台:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyArango\connection.py", line 88, in __init__
    self.reload()
  File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyArango\connection.py", line 107, in reload
    data = r.json()
  File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\models.py", line 812, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python35-32\lib\json\__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python35-32\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python35-32\lib\json\decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

https://www.arangodb.com/tutorials/tutorial-python/ and https://github.com/tariqdaouda/pyArango的在线tutorial/Documentation表示支持ArangoDB3.x和Python3.4。有没有其他人在尝试将 Python 3.5 与 pyArango 驱动程序一起使用时遇到此问题?如果有,这个问题有解决方案吗?

谢谢

我们更新了教程 - 它缺少身份验证步骤。

但是,我无法收到您关于 json 解析器失败的错误消息;我得到:

>>> myConnection = Connection()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/pyArango-1.1.0-py3.5.egg/pyArango/connection.py", line 88, in __init__
  File "/usr/local/lib/python3.5/dist-packages/pyArango-1.1.0-py3.5.egg/pyArango/connection.py", line 105, in reload
  File "/usr/local/lib/python3.5/dist-packages/pyArango-1.1.0-py3.5.egg/pyArango/connection.py", line 30, in __call__
pyArango.theExceptions.ConnectionError: Unauthorized access, you must supply a (username, password) with the correct credentials. URL: http://localhost:8529/_api/database/user, status: 401. Errors: b''

这是预期的错误消息。

问题是由 firewall/proxy 阻止来自 python http 客户端的 http 请求引起的。 firewall/proxy 返回一个 html 错误页面,当它被 pyArango 使用的 json 解析器处理时导致 json 解码错误。 pyArango 的维护者在 json 解码失败时添加了一个日志输出,使这种错误情况变得显而易见。 firewall/proxy 未阻止使用 firefox 等浏览器访问 arango 服务器的尝试。