簡體   English   中英

如何在 Anaconda 中的 Jupyter notebook 中使用 Python 連接 Cassandra?

[英]How to connect Cassandra in Jupyter notebook In Anaconda with Python?

我正在嘗試在我的計算機上使用 Cassandra。 我做了什么:

! pip install cassandra-driver

成功安裝 cassandra-driver-3.24.0 geomet-0.2.1.post1

import Cassandra

創建到數據庫的連接

然后連接數據庫

from cassandra.cluster import Cluster
try: 
    cluster = Cluster(['127.0.0.1']) 
    session = cluster.connect()
except Exception as e:
    print(e)

有一個錯誤:

('Unable to connect to any servers', {'127.0.0.1:9042': ConnectionRefusedError(10061, "Tried connecting to [('127.0.0.1', 9042)]. Last error: No connection could be made because the target machine actively refused it")})

我想知道是否有配置問題,然后我檢查以下: Java_Hone 的用戶變量如下: 在此處輸入圖片說明

Cassandra 安裝在這里:
C:\\Users\\xx\\anaconda3\\Lib\\site-packages
site-packages下有兩個包:
在此處輸入圖片說明

我檢查了很多答案,但找不到解決方案。 我對配置不熟悉。 有人可以幫忙嗎? 謝謝。

我已經回答了您在community.datastax.com 上發布的相同問題。

您正在連接到localhost上的集群,但它沒有在那里運行,因此連接失敗。 您需要指定集群中節點的 IP 之一。

有關更多信息,請參閱我在https://community.datastax.com/questions/9162/ 中對您帖子的回答。 干杯!

我剛剛為 python 3 發布了一個 Jupyter 內核。請參閱cqljupter

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM