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>it is not so good, but i will try to contribute to the problem. i'm new in cassandra and had exactly the same problem while trying to import data into a cassandra table via the copy function. i connect to the server on which cassandra is installed through cqlsh installed on a virtual machine. so i have to specify the server ip address and the port while running the cqlsh command: # cqlsh ip_address port
i connected with the servername like that: # cqlsh myserver.example.com 9040 and i was connected and the copy fonction didn't work.</p>

<p>But connecting with the numerical ip address of the server (for example:</p>

<h1>cqlsh 127.0.0.1 9040) it has worked.</h1>

<p>it was by pure chance, i have simply tested and it has worked for me.</p>

<p>when someone here can explain this fact it would be great!</p>

python csv cassandra copy nonetype