ModuleNotFoundError: No module named 'cassandra.cluster'; 'cassandra' is not a package

1,688 views
Skip to first unread message

Morten Bjoernsvik

unread,
Jul 1, 2019, 8:53:02 AM7/1/19
to DataStax Python Driver for Apache Cassandra User Mailing List
Hi

When trying to start up cassandra today I got the following:

python3.7.3, windows10 pro 64bit,


I've removed the __pycache__ dir, and reinstalled:



(bptools) PS C:\dist\work\bptools> pip install cassandra-driver --force
Collecting cassandra-driver
 
Using cached https://files.pythonhosted.org/packages/1b/05/7af4db63dcc0f0cc72855f2b31daa07517cc6668d214d52134c44810cf58/cassandra-driver-3.18.0.tar.gz
Collecting six>=1.9 (from cassandra-driver)
 
Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Installing collected packages: six, cassandra-driver
 
Found existing installation: six 1.12.0
   
Uninstalling six-1.12.0:
     
Successfully uninstalled six-1.12.0
 
Found existing installation: cassandra-driver 3.18.0
   
Uninstalling cassandra-driver-3.18.0:
     
Successfully uninstalled cassandra-driver-3.18.0
 
Running setup.py install for cassandra-driver ... done
Successfully installed cassandra-driver-3.18.0 six-1.12.0


(bptools) PS C:\dist\work\bptools> pip freeze | findstr cassandra
cassandra
-driver==3.18.0


python
.exe -vv .\bptools\cassandra.py

# C:\dist\work\bptools\bptools\__pycache__\cassandra.cpython-37.pyc matches C:\dist\work\bptools\bptools\cassandra.py
# code object from 'C:\\dist\\work\\bptools\\bptools\\__pycache__\\cassandra.cpython-37.pyc'
Traceback (most recent call last):
 
File ".\bptools\cassandra.py", line 12, in <module>
   
from cassandra.cluster import Cluster
 
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
 
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
 
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
 
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
 
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
 
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
 
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
 
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
 
File "C:\dist\work\bptools\bptools\cassandra.py", line 12, in <module>
   
from cassandra.cluster import Cluster
 
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
 
File "<frozen importlib._bootstrap>", line 962, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'cassandra.cluster'; 'cassandra' is not a package



Alan Boudreault

unread,
Jul 2, 2019, 9:18:24 AM7/2/19
to python-dr...@lists.datastax.com
Hello,

It looks like your issue is related to the name of your file: cassandra.py. The Python script is trying to import itself.

$ cat test/cassandra.py 
from cassandra.cluster import Cluster

$ python test/cassandra.py
Traceback (most recent call last):
  File "test/cassandra.py", line 1, in <module>
    from cassandra.cluster import Cluster
  File "/tmp/test/cassandra.py", line 1, in <module>
    from cassandra.cluster import Cluster

ModuleNotFoundError: No module named 'cassandra.cluster'; 'cassandra' is not a package

$ mv test/cassandra.py test/cass.py
$ python test/cass.py
$


--
To unsubscribe from this group and stop receiving emails from it, send an email to python-driver-u...@lists.datastax.com.


--

Alan Boudreault
Software Engineer (Drivers) | alan.bo...@datastax.com


Reply all
Reply to author
Forward
0 new messages