2

I want to use pyarango-library in python to connect to arrangodb, but I cannot even get connected. Here is the code using 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

And this is the error I get:

  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

I can't find any related threads on it, can somebody help me with this?

Solution:

I first did a: pip install requests and got:

Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python2.7/dist-packages 

But it wasnt sufficient...so I had to upgrade it/force it:

    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

Now it connects, and the self.conn[etc].. I just deleted the: self. and went like this:

try:
    conn.createDatabase(name = "test_db2")
except Exception as e:
    print "conn could not createDatabase(name = test_db)"
    print e

And it worked!! THANK YOU MARTIJN!!!

nb! the error I mentioned last was only because the db already existed.

4
  • 1
    You are using an older version of the requests library. Is this on Ubuntu? Is python-requests system installed and version 0.8.x perhaps? Commented Feb 14, 2015 at 22:48
  • Im not exactly sure what the requests library is actually. This is kali linux/debian wheezy-base. So I will try to install python-requests system...be back Commented Feb 14, 2015 at 23:23
  • With pip install requests - It said this: Successfully installed requests-2.5.1 But then another error occures: NameError: name 'self' is not defined Seems it cant recognize the: self.conn[etc..] Commented Feb 14, 2015 at 23:30
  • Thanks for the issue, I've updated the setup.py so that pyArango now requires requests>=2.7.0. Commented Aug 7, 2015 at 17:20

1 Answer 1

2

Your error indicates that you are using an old requests version; response.json() became a method in requests version 1.0. Your local installation predates this.

Either you have an old release installed as an OS package, or by you yourself. You need to upgrade that package.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.