File "/var/lib/jenkins/jobs/dev_test/workspace/.buildout/eggs/cassandra_driver-2.0.1-py2.7-linux-x86_64.egg/cassandra/cluster.py", line 46, in <module>
from cassandra.connection import ConnectionException, ConnectionShutdown
File "/var/lib/jenkins/jobs/dev_test/workspace/.buildout/eggs/cassandra_driver-2.0.1-py2.7-linux-x86_64.egg/cassandra/connection.py", line 26, in <module>
from six.moves.queue import Queue, Empty # noqa
ImportError: No module named queue
The reason is six lib in system is out-of-date issue.
Run python -c "import six; print six.__version__" to check the version of six
The solution is to use virtual environment
$ sudo pip install virtualenv
$ ./env/bin/pip install cassandra-driver
$ ./env/bin/python
Sample code:
from cassandra import ConsistencyLevel from cassandra.cluster import Cluster cluster = Cluster(['127.0.0.1']) session = cluster.connect() session.execute(""" CREATE KEYSPACE IF NOT EXISTS %s WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '1' } """ % KEYSPACE) session.set_keyspace(KEYSPACE) session.execute(""" CREATE TABLE IF NOT EXISTS Preciptation ( country text, value double, PRIMARY KEY (country))""") insertData = session.prepare(""" INSERT INTO Preciptation (country, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""") pr = ("Canada",20) session.execute(insertData, pr) session.execute("DROP KEYSPACE " + KEYSPACE) cluster.shutdown()
https://datastax-oss.atlassian.net/browse/PYTHON-77
No comments:
Post a Comment