"'Bucket' object has no attribute 'mc_client'" - latest python sdk broken?
It appears that the python sdk 0.8.0 has changed sine few weeks ago... I have two different environments with both the version 0.8.0... One was installed 3 weeks ago and one this morning. (pip install) ???
Files batch/lib/python2.7/site-packages/couchbase/__init__.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/__init__.pyc differ Files batch/lib/python2.7/site-packages/couchbase/client.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/client.pyc differ Files batch/lib/python2.7/site-packages/couchbase/constants.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/constants.pyc differ Files batch/lib/python2.7/site-packages/couchbase/couchbaseclient.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/couchbaseclient.pyc differ Files batch/lib/python2.7/site-packages/couchbase/event.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/event.pyc differ Files batch/lib/python2.7/site-packages/couchbase/exception.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/exception.pyc differ Files batch/lib/python2.7/site-packages/couchbase/logger.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/logger.pyc differ Files batch/lib/python2.7/site-packages/couchbase/memcachedclient.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/memcachedclient.pyc differ Files batch/lib/python2.7/site-packages/couchbase/migrator/__init__.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/migrator/__init__.pyc differ Files batch/lib/python2.7/site-packages/couchbase/migrator/migrator.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/migrator/migrator.pyc differ Files batch/lib/python2.7/site-packages/couchbase/migrator/migrator_couchbase.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/migrator/migrator_couchbase.pyc differ Files batch/lib/python2.7/site-packages/couchbase/migrator/migrator_couchdb.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/migrator/migrator_couchdb.pyc differ Files batch/lib/python2.7/site-packages/couchbase/migrator/migrator_csv.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/migrator/migrator_csv.pyc differ Files batch/lib/python2.7/site-packages/couchbase/migrator/migrator_dir.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/migrator/migrator_dir.pyc differ Files batch/lib/python2.7/site-packages/couchbase/migrator/migrator_json.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/migrator/migrator_json.pyc differ Files batch/lib/python2.7/site-packages/couchbase/migrator/migrator_zip.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/migrator/migrator_zip.pyc differ Files batch/lib/python2.7/site-packages/couchbase/rest_client.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/rest_client.pyc differ Files batch/lib/python2.7/site-packages/couchbase/util.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/util.pyc differ Files batch/lib/python2.7/site-packages/couchbase/utils/__init__.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/utils/__init__.pyc differ Files batch/lib/python2.7/site-packages/couchbase/utils/couchbase-migrator.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/utils/couchbase-migrator.pyc differ Files batch/lib/python2.7/site-packages/couchbase/vbucketawareclient.pyc and lib-datastore/lib/python2.7/site-packages/couchbase/vbucketawareclient.pyc differ
import couchbase cb = couchbase.Couchbase(host='localhost:8091', username='Administrator', password='password') bucket = cb.bucket('default')
generate the following traceback:
Traceback (most recent call last):
File "cb_test.py", line 3, in <module>
bucket = cb.bucket('default')
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/couchbase/client.py", line 97, in bucket
return Bucket(bucket_name, self)
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/couchbase/client.py", line 196, in __init__
self.info = rest.get_bucket(self.name)
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/couchbase/rest_client.py", line 692, in get_bucket
status, content = self._http_request(api)
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/couchbase/rest_client.py", line 294, in _http_request
auth=(self.username, self.password))
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/requests/api.py", line 65, in get
return request('get', url, **kwargs)
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/requests/safe_mode.py", line 39, in wrapped
return function(method, url, **kwargs)
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/requests/api.py", line 51, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/requests/sessions.py", line 182, in request
params=from_key_val_list(params),
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/requests/utils.py", line 135, in from_key_val_list
raise ValueError('cannot encode objects that are not 2-tuples')
ValueError: cannot encode objects that are not 2-tuples
Exception AttributeError: "'Bucket' object has no attribute 'mc_client'" in <bound method Bucket.__del__ of <couchbase.client.Bucket object at 0x1009c6bd0>> ignored
<code>
Is this expected behavior?
Thanks.from couchbase.couchbaseclient import CouchbaseClient client = CouchbaseClient("http://localhost:8091/pools/default", "default", "",False)
is causing the following traceback
Traceback (most recent call last):
File "cb_test.py", line 4, in <module>
client = CouchbaseClient("http://localhost:8091/pools/default", "default", "",False)
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/couchbase/couchbaseclient.py", line 326, in __init__
self.bucket = self.rest.get_bucket(bucket)
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/couchbase/rest_client.py", line 692, in get_bucket
status, content = self._http_request(api)
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/couchbase/rest_client.py", line 294, in _http_request
auth=(self.username, self.password))
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/requests/api.py", line 65, in get
return request('get', url, **kwargs)
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/requests/safe_mode.py", line 39, in wrapped
return function(method, url, **kwargs)
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/requests/api.py", line 51, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/requests/sessions.py", line 182, in request
params=from_key_val_list(params),
File "/Users/alex/Envs/lib-datastore/lib/python2.7/site-packages/requests/utils.py", line 135, in from_key_val_list
raise ValueError('cannot encode objects that are not 2-tuples')
ValueError: cannot encode objects that are not 2-tuplesin rest_client.py
line 693 you are not passing any params to the self._http_request(api)
def get_bucket(self, bucket='default'): bucketInfo = None api = '/pools/default/buckets/{0}'.format(bucket) status, content = self._http_request(api)
so in line 294 you are passing an empty params to the requests call.
def _http_request(self, api, method='GET', params='', headers=None, timeout=120, base=None): if base is None: base = self.base_url if not headers: headers = self._create_headers() end_time = time.time() + timeout while True: try: api = ''.join([base, api]) if method == 'GET': print params r = requests.get(api, headers=headers, params=params, auth=(self.username, self.password))
this won't work with the requests package
ValueError: cannot encode objects that are not 2-tuples
Looks like the requests python module was updated and v0.14.1 broke CB SDK.
https://github.com/kennethreitz/requests/tree/v0.14.1
reverting requests to v0.14.0 solve the problem
I have temporary fixed the problem and commited:
https://github.com/alex-ethier/couchbase-python-client/commit/3efcda9e99...
Would love to create a bug but I can't.
Same story here... tryed to submit a bug and hit same error message... is there any way to fix / workaround it?
Hi Alexe001 and AlexD,
We'll have a look at the problem with Jira. Sorry for the hassle. I'll post back here.
Also, on the code commit, we have a change in already for the requests module and will be doing an update to 0.8 soon. It's been committed, we just need to change some things to get it into pypi.
Thanks,
Matt
Actually, I think we fixed the Jira issue just the other day already. Again, sorry for the hassle.
This problem still persists even after a fresh pip install. Any clues? I don't see any updates to the git repos in the last 4-5 months.
As I mentioned earlier, we're going to update pypi soon.
On the git repo update, most recent commit was 21 days ago:
https://github.com/couchbase/couchbase-python-client
Just for planning purposes, what is "soon"?
Any chance you can give me the patch so I don't have to wait for the pypy update?
Thanks.
Sure, there's a workaround posted in the issue:
http://www.couchbase.com/issues/browse/PYCBC-69
(it's also linked off the download page with a note)
You'll need to make the following change as well:
- bucket.controllers = parsed['controllers']
- bucket.ddocs = parsed['ddocs']
+ bucket.controllers = parsed.get('controllers', [])
+ bucket.ddocs = parsed.get('ddocs', [])
I am evaluating couchbase for integration with existing django app.
coucbase server 2.0.0 on aws instance
python 2.7
couchbase 0.8.1 (pip installed)
requests 0.14.2 (have also tried 0.14.0, and 0.14.1)
Similar error posted above is blocking. No notes on the referenced jira issue since October.
Could this be a bucket configuration error?
INFO Traceback (most recent call last):
File "/home/michael/projects/readrboard/api/decorators.py", line 15, in wrapper
dataout = func(*args, **kwargs)
File "/home/michael/projects/readrboard/api/decorators.py", line 52, in wrapper
return func(self, request, data, *args, **kwargs)
File "/home/michael/projects/readrboard/api/handlers.py", line 1002, in read
couch.migrate()
File "/home/michael/projects/readrboard/rb/couch.py", line 18, in migrate
inter_bucket = get_bucket("interaction")
File "/home/michael/projects/readrboard/rb/couch.py", line 57, in get_bucket
bucket = couch[type]
File "/usr/lib/python2.7/site-packages/couchbase/client.py", line 141, in __getitem__
return self.bucket(key)
File "/usr/lib/python2.7/site-packages/couchbase/client.py", line 97, in bucket
return Bucket(bucket_name, self)
File "/usr/lib/python2.7/site-packages/couchbase/client.py", line 196, in __init__
self.info = rest.get_bucket(self.name)
File "/usr/lib/python2.7/site-packages/couchbase/rest_client.py", line 699, in get_bucket
error=status)
BucketUnavailableException: unable to find bucket interaction on the host @ XXX.XXX.XXX.XXXConfiguration problem with the client. PEBKAC.
I'm confused about the sdk versions now..
On github git://github.com/couchbase/couchbase-python-client.git
there is a 0.8.0 tag that had activity about a month ago and there is a 1.8.0 that had activity about 10 months ago.
The latest branch seem to be 1.8.1. What version should be used with cb 2.0 and is the version installed with pip (0.8.0)
the "correct" one ( 0.8.0 is causing the previous issues.)?
Thanks,
A