【问题标题】:How to connect Cassandra in Jupyter notebook In Anaconda with Python?如何在 Anaconda 中使用 Python 连接 Jupyter notebook 中的 Cassandra?
【发布时间】:2021-02-22 06:12:33
【问题描述】:

我正在尝试在我的计算机上使用 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 下有两个包:

我已经检查了很多答案,但找不到解决方案。我不熟悉配置。有人可以帮忙吗? 谢谢。

【问题讨论】:

    标签: python cassandra jupyter-notebook


    【解决方案1】:

    我已经回复了您在community.datastax.com 上发布的同样问题。

    您正在连接到localhost 上的集群,但它没有在那里运行,因此连接失败。您需要指定集群中节点的 IP 之一。

    有关详细信息,请参阅我在 https://community.datastax.com/questions/9162/ 中对您的帖子的回答。干杯!

    【讨论】:

    • 亲爱的埃里克,感谢您的回答。我可能离你提到的步骤有点远,因为我随后尝试在 CMD 中运行 Cassandra,它显示 1. PowerShell Set-ExecutionPolicy 需要更改 2. 无法创建 JVM。我的 Java 版本是 13,Cassandra 版本 3 可能只支持 Java 8?
    • @Annie 没错,Cassandra 3 可能无法在 Java 13 上运行。
    • 亚伦是正确的。 Cassandra 3.x 仅适用于 Java 8。C* 4.0 最终将支持 Java 11。干杯!
    • Apache 发行说明说 Java >= 1.8 支持 Cassandra 3.11,请参阅 github.com/apache/cassandra/tree/cassandra-3.11 中的“要求”。我在 Java 11 上运行它就好了。
    【解决方案2】:

    我已经为 Cassandra CQL 发布了一个 Jupyter 内核。见cqljupter

    【讨论】:

      猜你喜欢
      • 2021-08-13
      • 2017-01-02
      • 2018-07-31
      • 1970-01-01
      • 2020-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-16
      相关资源
      最近更新 更多