我想用cassandra python驱动程序使用ipython笔记本。使用命令行ipython是完全正确的;我能够建立连接。但是,当我使用具有相同代码的Jupyter IPython笔记本时,遇到连接错误。使用Jupyter IPython和Cassandra驱动程序
from cassandra.cluster import Cluster
cluster = Cluster(contact_points=['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'])
session = cluster.connect()
我可以通过命令行使用ipython和python运行上面的3行。
WARNING:cassandra.cluster:Failed to create connection pool for new host 10.0.0.7
...
error: [Errno None] Tried connecting to [('10.0.0.7', 9042)]. Last error: None
WARNING:cassandra.pool:Error attempting to reconnect to 10.0.0.7, scheduling retry in 2.0 seconds: [Errno None] Tried connecting to [('10.0.0.7', 9042)]. Last error: None
(我用的卡珊德拉蟒蛇司机pip install cassandra-driver
)
难道是一个IP地址或路由问题:在jupyter执行代码时IPython的笔记本我得到的错误?为“新主机”提到的错误消息指向一个本地IP地址,而不是我用来连接的地址。如果是这样的话,我想知道为什么ipython命令行与笔记本产生不同的结果,所以它与笔记本如何处理连接有关。有没有人有任何见解,为什么这是这种情况,并可能如何解决或解决此连接错误?