Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python py2neo SocketError:连接被拒绝,但curl可以工作_Python_Neo4j_Py2neo - Fatal编程技术网

Python py2neo SocketError:连接被拒绝,但curl可以工作

Python py2neo SocketError:连接被拒绝,但curl可以工作,python,neo4j,py2neo,Python,Neo4j,Py2neo,我试图在远程Ubuntu服务器上安装一个Flask/Neo4j应用程序,但我遇到了一个无法解决的问题。我的应用程序使用py2neo,但当它试图连接到图形时,应用程序崩溃,Neo4j进程似乎停止了。我尝试过在python shell中连接,如下所示 test = Graph('http://localhost:7474/db/data/',username='neo4j',password='myPassword') 这会失败,并且会导致neo4j无法工作,直到我重新启动它。但是,这些将返回20

我试图在远程Ubuntu服务器上安装一个Flask/Neo4j应用程序,但我遇到了一个无法解决的问题。我的应用程序使用py2neo,但当它试图连接到图形时,应用程序崩溃,Neo4j进程似乎停止了。我尝试过在python shell中连接,如下所示

test = Graph('http://localhost:7474/db/data/',username='neo4j',password='myPassword')
这会失败,并且会导致neo4j无法工作,直到我重新启动它。但是,这些将返回
200个
响应(web界面也可以工作):

我试图提供更多的信息,因为似乎除了py2neo之外,其他地方的连接都能正常工作

以下是完整的回溯:

Traceback (most recent call last):
  File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/database/__init__.py", line 318, in __new__
    inst = cls.__instances[key]
KeyError: (<class 'py2neo.database.Graph'>, <ServerAddress settings={'http_port': 7474, 'host': 'localhost'}>, 'data')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 322, in submit
    response = send()
  File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 317, in send
    http.request(xstr(method), xstr(uri.absolute_path_reference), body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1106, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1151, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.5/http/client.py", line 1102, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.5/http/client.py", line 934, in _send_output
    self.send(msg)
  File "/usr/lib/python3.5/http/client.py", line 877, in send
    self.connect()
  File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 80, in connect
    self.source_address)
  File "/usr/lib/python3.5/socket.py", line 711, in create_connection
    raise err
  File "/usr/lib/python3.5/socket.py", line 702, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/database/__init__.py", line 327, in __new__
    use_bolt = version_tuple(inst.__remote__.get().content["neo4j_version"]) >= (3,)
  File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/database/http.py", line 154, in get
    response = self.__base.get(headers=headers, redirect_limit=redirect_limit, **kwargs)
  File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 966, in get
    return self.__get_or_head("GET", if_modified_since, headers, redirect_limit, **kwargs)
  File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 943, in __get_or_head
    return rq.submit(redirect_limit=redirect_limit, **kwargs)
  File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 433, in submit
    http, rs = submit(self.method, uri, self.body, self.headers)
  File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 362, in submit
    raise SocketError(code, description, host_port=uri.host_port)
py2neo.packages.httpstream.http.SocketError: Connection refused
回溯(最近一次呼叫最后一次):
文件“/home/deploy/toponimika/toponimikaenv/lib/python3.5/site packages/py2neo/database/_init____;.py”,第318行,新文件__
inst=cls.\u实例[键]
KeyError:(,“数据”)
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/home/deploy/toponimika/toponimikaenv/lib/python3.5/site packages/py2neo/packages/httpstream/http.py”,第322行,提交
响应=发送()
文件“/home/deploy/toponimika/toponimikaenv/lib/python3.5/site packages/py2neo/packages/httpstream/http.py”,第317行,在send中
请求(xstr(方法)、xstr(uri.absolute_path_引用)、主体、头)
请求中的文件“/usr/lib/python3.5/http/client.py”,第1106行
self.\u发送请求(方法、url、正文、标题)
文件“/usr/lib/python3.5/http/client.py”,第1151行,在发送请求中
self.endheaders(主体)
文件“/usr/lib/python3.5/http/client.py”,第1102行,在endheaders中
自发送输出(消息体)
文件“/usr/lib/python3.5/http/client.py”,第934行,在发送输出中
self.send(msg)
文件“/usr/lib/python3.5/http/client.py”,第877行,在send中
self.connect()
文件“/home/deploy/toponimika/toponimikaenv/lib/python3.5/site packages/py2neo/packages/httpstream/http.py”,第80行,在connect中
self.source(地址)
文件“/usr/lib/python3.5/socket.py”,第711行,在create_connection中
提出错误
文件“/usr/lib/python3.5/socket.py”,第702行,在create_connection中
sock.connect(sa)
ConnectionRefusedError:[Errno 111]连接被拒绝
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/home/deploy/toponimika/toponimikaenv/lib/python3.5/site packages/py2neo/database/_init__.py”,第327行,在新的__
使用\u bolt=version\u tuple(inst.\uu remote\uuuu.get().content[“neo4j\u version]”)>=(3,)
文件“/home/deploy/toponimika/toponimikaenv/lib/python3.5/site packages/py2neo/database/http.py”,get中第154行
response=self.\uuuu base.get(headers=headers,redirect\u limit=redirect\u limit,**kwargs)
文件“/home/deploy/toponimika/toponimikaenv/lib/python3.5/site packages/py2neo/packages/httpstream/http.py”,第966行,在get中
返回self.\u获取\u或\u头(“获取”,如果\u修改\u自,头,重定向\u限制,**kwargs)
文件“/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py”,第943行,在get或head中
返回rq.submit(重定向限制=重定向限制,**kwargs)
文件“/home/deploy/toponimika/toponimikaenv/lib/python3.5/site packages/py2neo/packages/httpstream/http.py”,第433行,在提交中
http,rs=submit(self.method,uri,self.body,self.headers)
文件“/home/deploy/toponimika/toponimikaenv/lib/python3.5/site packages/py2neo/packages/httpstream/http.py”,第362行,在提交中
raise SocketError(代码、说明、主机\u端口=uri.host\u端口)
py2neo.packages.httpstream.http.SocketError:连接被拒绝

如果我想知道发生了什么,我将不胜感激。

更改为
http://username:password@localhost:7474/db/data/
它可以正常工作

例如:

test = Graph('http://username:password@localhost:7474/db/data/')

我也有同样的问题,通过简单升级pip版本就解决了

pip安装——升级py2neo

test = Graph('http://username:password@localhost:7474/db/data/')