我想用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命令行與筆記本產生不同的結果,所以它與筆記本如何處理連接有關。有沒有人有任何見解,爲什麼這是這種情況,並可能如何解決或解決此連接錯誤?