'ModuleNotFoundError: No module named 'cassandra.cluster'; 'cassandra' is not a package
I tried pip install cassandra-driver
inside pycharm terminal, conda command prompt in admin mode, I upgraded/degraded versions of cassandra-driver, restarted pycharm , created new env ,still showing error.
Here is my code .
import cassandra
from cassandra.cluster import Cluster
my error massage:
C:\Anaco3.8\envs\FlipScap\python.exe
C:/Users/Rushikesh/Downloads/FlipkratScrappingProject/cassan2.py
Traceback (most recent call last):
File "C:/Users/Rushikesh/Downloads/FlipkratScrappingProject/cassan2.py", line 1, in <module>
import cassandra
File "C:\Users\Rushikesh\Downloads\FlipkratScrappingProject\cassandra.py", line 3, in <module>
from cassandra.cluster import Cluster
ModuleNotFoundError: No module named 'cassandra.cluster'; 'cassandra' is not a package
Solution 1:[1]
The error indicatest that the Cassandra Python driver is not installed.
If you haven't already, try installing it with:
$ pip3 install cassandra-driver
Check that the installation was successful by running:
$ python -c 'import cassandra; print cassandra.__version__'
If it is installed correctly, you should get something like "3.25.0".
Solution 2:[2]
I think we can blame our dear DataStax for this, they mentioned Cluster with no camel-case and it cause this issue.
first make sure you have the package installed(pip3 install cassandra-driver), then use bellow code.
Just use it this way:
from cassandra.cluster import Cluster
cluster = Cluster(['172...', '172...','172...'])
Replace all the '172...' with your cluster IP set.
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 | desertnaut |
| Solution 2 |
