weixin_39605894
2020-12-09 05:12 阅读 8

Getting ImportError: No module named document for any cloudant import

Hi, I'm trying to use cloudant-python library in my application, but I'm not able to import the library itself as I'm getting ImportError: No module named document as soon as I try to import anything from cloudant context. Following are details:

  • Cloudant version: cloudant-2.6.1.dev0
  • Python version: Python 2.7.9
  • Example code which is giving error
python
from cloudant.account import Cloudant

OR

python
from cloudant.client import Cloudant

OR

python
from cloudant import Cloudant

The error is as follows:


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cloudant.py", line 3, in <module>
    from cloudant.document import Document
ImportError: No module named document
</module></module></stdin>

该提问来源于开源项目:cloudant/python-cloudant

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

6条回答 默认 最新

  • weixin_39595931 weixin_39595931 2020-12-09 05:12

    I can't reproduce this.

    Have you installed the library correctly with pip install cloudant?

    You appear to be trying to use a dev version which is not supported.

    点赞 评论 复制链接分享
  • weixin_39605894 weixin_39605894 2020-12-09 05:12

    I tried with pip install cloudant, was receiving the same error so I uninstalled and tried with dev version by installing with pip install git+https://github.com/cloudant/python-cloudant.

    Still the issue is the same.

    点赞 评论 复制链接分享
  • weixin_39595931 weixin_39595931 2020-12-09 05:12

    The latest released version should work; for example this test script works fine for me:

    python
    from cloudant.client import Cloudant
    client = Cloudant("tomblench", "XXXX", account="tomblench", connect=True)
    session = client.session()
    print 'Username: {0}'.format(session['userCtx']['name'])
    print 'Databases: {0}'.format(client.all_dbs())
    
    点赞 评论 复制链接分享
  • weixin_39605894 weixin_39605894 2020-12-09 05:12

    issue is resolved as soon as I refreshed the session, duh!

    点赞 评论 复制链接分享
  • weixin_39595931 weixin_39595931 2020-12-09 05:12

    OK no problem 😄

    点赞 评论 复制链接分享
  • weixin_39747341 weixin_39747341 2020-12-09 05:12

    I just set export PYTHONPATH=/usr/local/lib/python2.7/site-packages which cloudant lib exists.

    点赞 评论 复制链接分享

相关推荐