'How to connect Cassandra in Jupyter notebook In Anaconda with Python?
I am trying to use Cassandra on my computer. What I have done:
! pip install cassandra-driver
Successfully installed cassandra-driver-3.24.0 geomet-0.2.1.post1
import Cassandra
Create a connection to the database
Then the connection to the database
from cassandra.cluster import Cluster
try:
cluster = Cluster(['127.0.0.1'])
session = cluster.connect()
except Exception as e:
print(e)
There is an error:
('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")})
I am wondering whether there is a configuration problem, then I check below:
The user variable for Java_Hone as below:

Cassandra is installed here:
C:\Users\xx\anaconda3\Lib\site-packages
There are two packages under site-packages:
I have checked a lot of answers, but couldn't find the solution. I am not familiar with the configuration. Can anybody help with it? Thanks.
Solution 1:[1]
I've responded to this same question you posted on community.datastax.com.
You're connecting to the cluster on localhost and it's not running there so the connection fails. You need to specify one of the IPs of the nodes in the cluster.
For more info, see my answer to your post in https://community.datastax.com/questions/9162/. Cheers!
Solution 2:[2]
I've released a Jupyter kernel for Cassandra CQL. See cqljupter.
Solution 3:[3]
The simplest way to do it:
! pip install cassandra-driver
Then connect to your local host and the required space
from cassandra.cluster import Cluster
cluster = Cluster()
session = cluster.connect('keyspace')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Erick Ramirez |
| Solution 2 | |
| Solution 3 | Ethan |
