title: How to add an edge to existing and new vertices in gremlin-python?
body: <p>I've already seen this answer:
  <a href="https://stackoverflow.com/questions/44200374/gremlin-how-to-add-edge-to-existing-vertex-in-gremlin-python">Gremlin, How to add edge to existing vertex in gremlin-python</a>
  and it wasn't really helpful. As suggested in one of the comments I did try to update gremlinpython 3.3.0 but then I get key error.</p>
  
  <p><strong>Stack:</strong>
  JanusGraph 0.2.0, gremlinpython3.2.3</p>
  
  <p><strong>This is my code</strong></p>
  
  <pre><code>from gremlin_python import statics
  from gremlin_python.structure.graph import Graph
  from gremlin_python.process.graph_traversal import __
  from gremlin_python.process.strategies import *
  from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
  
  graph = Graph()
  g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
  martha = g.V().has('name','martha').next()
  jack = g.V().has('name','jack').next()
  #e_id = g.addE(jack,'likes',martha).next()
  e_id = g.V(martha).as_('to').V(jack).addE("Likes").to('to').toList()
  print e_id.toList()
  </code></pre>
  
  <p><strong>StackTrace with gremlinpython 3.3.0</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "gremlin-py.py", line 9, in &lt;module&gt;
      martha = g.V().has('name','martha').next()
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 70,in next
      return self.__next__()
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 43,in __next__
      self.traversal_strategies.apply_strategies(self)
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 352, in apply_strategies
      traversal_strategy.apply(traversal)
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/remote_connection.py", line 143, in apply
      remote_traversal = self.remote_connection.submit(traversal.bytecode)
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 54, in submit
      results = result_set.all().result()
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/concurrent/futures/_base.py", line 429, in result
      return self.__get_result()
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/concurrent/futures/_base.py", line 381, in __get_result
      raise exception_type, self._exception, self._traceback
  KeyError: None
  </code></pre>
  
  <p>In my case, <code>3.3.0</code> is throwing error for all queries including <code>g.V().next()</code>. Now going back to 3.2.3, addvertex and other queries are working absolutely fine, but I couldn't figure out how to add edges. The same code when run with 3.2.3 produces,</p>
  
  <p><strong>StackTrace with gremlinpython 3.2.3</strong></p>
  
  <pre><code>Traceback (most recent call last):  File "gremlin-py.py", line 12, in &lt;module&gt;
      e_id = g.V(martha).as_('to').V(jack).addE("Likes").to('to').toList()
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 52, in toList    return list(iter(self))
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 70, in next
      return self.__next__()  File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 43, in __next__
      self.traversal_strategies.apply_strategies(self)  File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 284, in apply_strategies
      traversal_strategy.apply(traversal)
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/remote_connection.py", line 95, in apply    remote_traversal = self.remote_connection.submit(traversal.bytecode)  File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 53, in submit    traversers = self._loop.run_sync(lambda: self.submit_traversal_bytecode(request_id, bytecode))
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/tornado/ioloop.py", line 457, in run_sync
      return future_cell[0].result()  File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/tornado/concurrent.py", line 237, in result
      raise_exc_info(self._exc_info)
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/tornado/gen.py", line 285, in wrapper
      yielded = next(result)
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 69, in submit_traversal_bytecode
      "gremlin": self._graphson_writer.writeObject(bytecode),
    File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/structure/io/graphson.py", line 72, in writeObject
      return json.dumps(self.toDict(objectData), separators=(',', ':'))
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 250, in dumps
      sort_keys=sort_keys, **kw).encode(obj)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 207, in encode
      chunks = self.iterencode(o, _one_shot=True)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 270, in iterencode
      return _iterencode(o, 0)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 184, in default
      raise TypeError(repr(o) + " is not JSON serializable")
  TypeError: v[4184] is not JSON serializable
  </code></pre>
  
  <p>It says <code>v[x]</code> is not JSON serializable. I'm not sure what causes this error. It'll be awesome if someone can help. If any more info is needed, I shall update the question accordingly.</p>