【发布时间】:2018-04-12 22:30:53
【问题描述】:
我使用 Python 3.5,并通过执行命令安装了 cloudant 包:
sudo -H pip3 install cloudant
我尝试连接 python 数据库。根据文档 - https://console.bluemix.net/docs/services/Cloudant/getting-started.html#getting-started-with-cloudant。这段代码应该可以工作:
from cloudant.client import Cloudant
client = Cloudant("username", "password", url="https://user_name.cloudant.com")
client.connect()
client.disconnect()
当我运行它时,我得到一个错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tomek/Projects/stage-control/cloudant.py", line 1, in <module>
from cloudant.client import Cloudant
ImportError: No module named 'cloudant.client'; 'cloudant' is not a package
【问题讨论】:
-
在命令行输入
pip show cloudant。报告什么?如果没有,则没有安装该软件包。此外,您很少希望使用sudo安装软件包。只需以普通用户的身份进行即可。见What are the risks of running 'sudo pip'?
标签: python cloudant python-cloudant