2017-11-10 14 views
1

私は既にこの回答を見てきました: Gremlin, How to add edge to existing vertex in gremlin-python 本当に役に立たなかったです。コメントの1つに示唆しているように、gremlinpython 3.3.0を更新しようとしましたが、キーエラーが発生します。gremlin-pythonの既存の頂点と新しい頂点にエッジを追加するにはどうすればいいですか?

スタック: JanusGraph 0.2.0、gremlinpython3.2.3

これは私のコードで

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() 

gremlinpythonとのStackTrace 3.3.0

Traceback (most recent call last): 
    File "gremlin-py.py", line 9, in <module> 
    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 

です私の場合、を含むすべてのクエリでがスローエラーになりました。今度は3.2.3に戻って、addvertexや他のクエリは絶対にうまくいきますが、エッジを追加する方法を理解できませんでした。 3.2.3で実行する同じコードは、gremlinpython 3.2.3

Traceback (most recent call last): File "gremlin-py.py", line 12, in <module> 
    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 

スタックトレース作り出すことがv[x]はJSON直列化可能ではないと言います。このエラーの原因はわかりません。誰かが助けることができれば素晴らしいだろう。それ以上の情報が必要な場合は、それに応じて質問を更新します。

答えて

1

JanusGraph 0.2.0はApache TinkerPop 3.2.6を使用します。ドライバのgremlinpythonの3.2.6バージョンを使用する必要があります。

pip uninstall gremlinpython 
pip install gremlinpython==3.2.6 
+0

ありがとうございます。週末後に試してみる。 – Arvind

関連する問題