类型错误:';dict';对象在connecting-Arangodb-Python中不可调用
我想使用python中的-library连接到arrangodb,但我甚至无法连接。以下是使用python 2.7的代码:类型错误:';dict';对象在connecting-Arangodb-Python中不可调用,python,connection,arangodb,Python,Connection,Arangodb,我想使用python中的-library连接到arrangodb,但我甚至无法连接。以下是使用python 2.7的代码: from pyArango.connection import Connection conn = Connection() conn.createDatabase(name = "test_db") db = self.conn["test_db"] #all databases are loaded automatically into the connection
from pyArango.connection import Connection
conn = Connection()
conn.createDatabase(name = "test_db")
db = self.conn["test_db"] #all databases are loaded automatically into the connection and are accessible in this fashion
collection = db.createCollection(name = "users") #all collections are also loaded automatically
# collection.delete() # self explanatory
这就是我得到的错误:
File "pyarango-test1.py", line 8, in
conn = Connection(arangoURL='http://localhost:8529') #or with just conn = Connection()
File "/usr/local/lib/python2.7/dist-packages/pyArango/connection.py", line 19, in init
self.reload()
File "/usr/local/lib/python2.7/dist-packages/pyArango/connection.py", line 27, in reload
data = r.json()
TypeError: 'dict' object is not callable
我找不到任何相关的线索,有人能帮我吗
解决方案:
我首先做了一个:pip安装请求
得到:
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python2.7/dist-packages
但这还不够……所以我不得不升级/强制升级:
sudo pip install --upgrade requests
and got:
Collecting requests from https://pypi.python.org/packages/py2.py3/r/requests/requests-2.5.1-py2.py3-none-any.whl#md5=11dc91bc96c5c5e0b566ce8f9c9644ab Downloading requests-2.5.1-py2.py3-none-any.whl (464kB) 100% |################################| 466kB 3.6MB/s Installing collected packages: requests Found existing installation: requests 0.12.1 Uninstalling requests-0.12.1: Successfully uninstalled requests-0.12.1
Successfully installed requests-2.5.1
现在它连接起来了,而self.conn[等等]。。我刚刚删除了:self。结果是这样的:
try:
conn.createDatabase(name = "test_db2")
except Exception as e:
print "conn could not createDatabase(name = test_db)"
print e
成功了!!谢谢你,玛蒂恩
注意!我上次提到的错误只是因为数据库已经存在。您的错误表明您正在使用旧的
请求版本response.json()。您的本地安装早于此
您可以将旧版本作为操作系统软件包安装,也可以自己安装。您需要升级该软件包。您使用的是较旧版本的请求
库。这在Ubuntu上吗?是否安装了python请求
系统,版本可能是0.8.x?我不太清楚请求库实际上是什么。这是kali linux/debian wheezy base。因此,我将尝试安装python请求系统…返回pip安装请求-它说:已成功安装请求-2.5.1,但随后发生另一个错误:NameError:name'self'未定义似乎无法识别:self.conn[etc]。感谢这个问题,我已更新setup.py,以便pyArango现在需要大于等于2.7.0的请求。