我想使用python中的pyarango-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 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 install requests,然后得到:
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python2.7/dist-packages 但这不是sufficient...so,我必须升级它/强制它:
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.connetc..我刚刚删除了: self。是这样的:
try:
conn.createDatabase(name = "test_db2")
except Exception as e:
print "conn could not createDatabase(name = test_db)"
print e它成功了!!谢谢MARTIJN!
注意!我上次提到的错误只是因为db已经存在。
发布于 2015-02-15 08:43:40
您的错误表明您正在使用旧的requests版本;response.json()已成为requests version 1.0中的一个方法。您的本地安装早于此。
您可以将旧版本作为操作系统软件包安装,也可以自己安装。您需要升级该程序包。
https://stackoverflow.com/questions/28521142
复制相似问题