尝试向 couchdb 发出请求时,HttpLib2 抛出错误

发布于 2024-09-26 11:14:32 字数 1388 浏览 6 评论 0原文

我正在Python2.6 中构建一个需要从CouchDb 获取数据的应用程序。我使用 CouchDB-0.8-py2.6 连接到数据库。 我正在使用这段代码:

import couchdb
server = couchdb.Server(url='http://localhost:5984/', full_commit=True, session=None)
db = server['databaseName']
doc = db['docId']
value = doc['value']
print(value)

在我的本地计算机(OSX)上,代码运行完美,但是当我尝试在 Debian 服务器上运行它时,我收到以下错误:

File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 165, in __getitem__
   db.resource.head() # actually make a request to the database
 File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 977, in head
   return self._request('HEAD', path, headers=headers, **params)
 File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 1010, in _request
   resp, data = _make_request()
 File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 1005, in _make_request
   body=body, headers=headers)
 File "/usr/local/lib/python2.6/dist-packages/httplib2-0.6.0-py2.6.egg/httplib2/__init__.py", line 1025, in request
   cached_value = self.cache.get(cachekey)
AttributeError: 'bool' object has no attribute 'get'

我尝试用 Google 搜索多次,但没有-一个似乎有同样的错误。有谁知道我在这里做错了什么?

I'm building an application in Python2.6 that needs to get data from CouchDb. I'm using CouchDB-0.8-py2.6 to connect to the database.
I'm using this code:

import couchdb
server = couchdb.Server(url='http://localhost:5984/', full_commit=True, session=None)
db = server['databaseName']
doc = db['docId']
value = doc['value']
print(value)

On my local machine (OSX) the code runs perfectly, but when I'm trying to run it on a Debian server, I get the following error:

File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 165, in __getitem__
   db.resource.head() # actually make a request to the database
 File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 977, in head
   return self._request('HEAD', path, headers=headers, **params)
 File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 1010, in _request
   resp, data = _make_request()
 File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 1005, in _make_request
   body=body, headers=headers)
 File "/usr/local/lib/python2.6/dist-packages/httplib2-0.6.0-py2.6.egg/httplib2/__init__.py", line 1025, in request
   cached_value = self.cache.get(cachekey)
AttributeError: 'bool' object has no attribute 'get'

I've tried to Google this numerous times and no-one seems to have the same error. Does anyone have an idea what I'm doing wrong here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北城孤痞 2024-10-03 11:14:32

您在服务器上使用不同版本的 CouchDB - CouchDB-0.7dev_r199。 CouchDB 不再使用 httplib2,因此如果您的开发环境和服务器环境大致相同,那么问题很可能会消失。

You're using a different version of CouchDB on the server - CouchDB-0.7dev_r199. CouchDB does not use httplib2 anymore, so if you get your development and server environments roughly the same the problem is quite likely to disappear.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文