首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError:在connecting - Arangodb Python中无法调用“”dict“”对象

TypeError:在connecting - Arangodb Python中无法调用“”dict“”对象
EN

Stack Overflow用户
提问于 2015-02-15 06:46:09
回答 1查看 1.6K关注 0票数 2

我想使用python中的pyarango-library连接到arrangodb,但我甚至无法连接。以下是使用python 2.7的代码:

代码语言:javascript
复制
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

下面是我得到的错误:

代码语言:javascript
复制
  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,然后得到:

代码语言:javascript
复制
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python2.7/dist-packages 

但这不是sufficient...so,我必须升级它/强制它:

代码语言:javascript
复制
    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。是这样的:

代码语言:javascript
复制
try:
    conn.createDatabase(name = "test_db2")
except Exception as e:
    print "conn could not createDatabase(name = test_db)"
    print e

它成功了!!谢谢MARTIJN!

注意!我上次提到的错误只是因为db已经存在。

EN

回答 1

Stack Overflow用户

发布于 2015-02-15 08:43:40

您的错误表明您正在使用旧的requests版本;response.json()已成为requests version 1.0中的一个方法。您的本地安装早于此。

您可以将旧版本作为操作系统软件包安装,也可以自己安装。您需要升级该程序包。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28521142

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档