将python代码连接到gephi时获取“ HandshakeError:无效的响应状态:404未找到”

问题描述 投票:0回答:1

我正在尝试使用Python代码创建图形。我需要在gephi中将其可视化。

我尝试了此python代码:

from gephistreamer import graph
from gephistreamer import streamer
stream = streamer.Streamer(streamer.GephiWS())
node_a = graph.Node("A",custom_property=1)
node_b = graph.Node("B")
node_b.property['custom_property']=2
stream.add_node(node_a,node_b)
edge_ab = graph.Edge(node_a,node_b,custom_property="hello")
stream.add_edge(edge_ab)

我的gephi Graph流媒体插件已作为主设备激活。当我运行python代码时,会发生如下错误:

HandshakeError                            Traceback (most recent call last)
<ipython-input-1-7856b7437ce1> in <module>()
      1 from gephistreamer import graph
      2 from gephistreamer import streamer
----> 3 stream = streamer.Streamer(streamer.GephiWS())
      4 
      5 # Create a node with a custom_property

/usr/local/lib/python2.7/dist-packages/gephistreamer/streamer.pyc in __init__(self, hostname, port, workspace)
    113         self.workspace = workspace
    114         self.websocket = self.Client(self._generate_url())
--> 115         self.websocket.connect()
    116     def _generate_url(self):
    117         return "ws://{hostname}:{port}/{workspace}?operation=updateGraph".format(hostname=self.hostname,

/usr/local/lib/python2.7/dist-packages/ws4py/client/__init__.pyc in connect(self)
    235 
    236         try:
--> 237             self.process_response_line(response_line)
    238             self.protocols, self.extensions = self.process_handshake_header(headers)
    239         except HandshakeError:

/usr/local/lib/python2.7/dist-packages/ws4py/client/__init__.pyc in process_response_line(self, response_line)
    300         protocol, code, status = response_line.split(b' ', 2)
    301         if code != b'101':
--> 302             raise HandshakeError("Invalid response status: %s %s" % (code, status))
    303 
    304     def process_handshake_header(self, headers):

HandshakeError: Invalid response status: 404 Not Found

任何人都可以帮助我吗?

python gephi
1个回答
0
投票

我刚刚看过您的问题,也在寻找解决方案。一些提示对我的运行很有帮助:

  1. 明确指定连接:streamer.GephiWS(hostname="localhost", port=8080, workspace="workspace0")
  2. 您应该在Gephi中重命名的工作空间标题,避免使用大写字符和空格。所有大写字符必须在python中转换为小写字符]
  3. 在浏览器中测试是否可以访问http://localhost:8080/workspace0
  4. 我把插件弄乱了。。我注意到它并没有真正重新启动以影响设置。我总是关闭项目并启动主服务器new
  5. 我将端口更改为8080之后的其他端口
© www.soinside.com 2019 - 2024. All rights reserved.