我正在尝试为ArangoDB使用PyArango驱动程序。我正在使用Python 3.5.2 for Windows(这是我的组织提供的)和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/和https://github.com/tariqdaouda/pyArango上的在线教程/文档表明支持ArangoDB 3.x和Python 3.4。是否有其他人在尝试使用Python 3.5和pyArango驱动程序时遇到此问题?如果有,这个问题有解决方案吗?
由于
答案 0 :(得分:1)
问题是由防火墙/代理阻止来自python http客户端的http请求引起的。防火墙/代理返回了一个html错误页面,该页面在由pyArango使用的json解析器处理时导致json解码错误。 pyArango的维护者在json解码失败时添加了一个日志输出,这使得这个错误情况变得明显。尝试使用Firefox等浏览器访问arango服务器未被防火墙/代理阻止。
答案 1 :(得分:0)
我们更新了教程 - 它缺少验证步骤。
但是,我无法收到有关失败的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''
这是预期的错误消息。