Cassandra error 'NoneType' object has no attribute 'datacenter' while importing csv
<p>I have set up a cassandra cluster with 3 nodes.</p>

<p>I am trying to do a simple export/ import using copy command, but it fails with the following error:</p>

<pre><code>cqlsh:walmart&gt; select * from test;

 store | date       | isholiday | dept
-------+------------+-----------+------
     1 | 22/04/1993 |     False |    1


cqlsh&gt; use walmart;
cqlsh:walmart&gt; copy test to 'test.csv';
'NoneType' object has no attribute 'datacenter'
</code></pre>

<p>I researched the error and every related link seems to point out to python problems.</p>

<p>I also installed python driver pip cassandra-driver. Inserting data manually works, but not through export/ import.</p>

<pre><code>cassandra@cassandra-srv01:~$ python -c 'import cassandra; print cassandra.__version__'
3.6.0
</code></pre>

<p>Ubuntu 16.04 64bit.</p>

<p>how can I fix this error?</p>

<p>the logs inside <code>$CASSANDRA_HOME/logs</code> don't have any entries regarding the error.</p>

<p>Traceback:</p>

<pre><code>Traceback (most recent call last):
  File "/usr/local/Cellar/cassandra/3.7/libexec/bin/cqlsh.py", line 1152, in onecmd
    self.handle_statement(st, statementtext)
  File "/usr/local/Cellar/cassandra/3.7/libexec/bin/cqlsh.py", line 1189, in handle_statement
    return custom_handler(parsed)
  File "/usr/local/Cellar/cassandra/3.7/libexec/bin/cqlsh.py", line 1907, in do_copy
    task = ImportTask(self, ks, table, columns, fname, opts, DEFAULT_PROTOCOL_VERSION, CONFIG_FILE)
  File "/usr/local/Cellar/cassandra/3.7/libexec/bin/../pylib/cqlshlib/copyutil.py", line 1061, in __init__
    CopyTask.__init__(self, shell, ks, table, columns, fname, opts, protocol_version, config_file, 'from')
  File "/usr/local/Cellar/cassandra/3.7/libexec/bin/../pylib/cqlshlib/copyutil.py", line 207, in __init__
    self.local_dc = shell.conn.metadata.get_host(shell.hostname).datacenter
AttributeError: 'NoneType' object has no attribute 'datacenter
</code></pre>

<p>The issue is with the build of cqlsh that you are using, In that build copyutil is not using correct host to connect. It has been <a href="http://mail-archives.apache.org/mod_mbox/cassandra-commits/201607.mbox/%3Cfe01c229440a4ac6a05f776a666548ad@git.apache.org%3E" rel="nofollow">fixed</a> in the new releases. Just clone the <a href="https://github.com/apache/cassandra" rel="nofollow">repo</a> and run <code>bin/cqlsh</code> and try the same commands.</p>

python csv cassandra copy nonetype