使用Neo4j驱动程序进行python服务不可用错误 [英] Service unavailable error using neo4j driver for python

查看:730
本文介绍了使用Neo4j驱动程序进行python服务不可用错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是neo4j的新手,正在尝试执行neo4j网站中提供的演示项目(电影搜索).这样做时,我从python实例化neo4j服务器时遇到错误.另外,我可以在外部启动并运行neo4j服务器并使用它.请找到python代码段和错误详细信息-

I am new to neo4j and trying to execute the demo project(Movie search) provided in neo4j website. While doing so I am getting an error to instantiate neo4j server from python. Alternatively, I am able to up and run neo4j server externally and use it. Please find the python code snippet and error details -

import os
from json import dumps
from flask import Flask, g, Response, request
from neo4j.v1 import GraphDatabase, basic_auth
app = Flask(__name__, static_url_path='/static/')
password = os.getenv("NEO4J_PASSWORD")
driver = GraphDatabase.driver('bolt://localhost',auth=basic_auth("neo4j", password))
.
.

当我运行上面提到的代码时,我收到以下错误消息:

when I run this above mention code I get the following error message:

Traceback (most recent call last):
File "movies.py", line 12, in <module>
driver = GraphDatabase.driver('bolt://localhost',auth=basic_auth("neo4j", password))
File "C:\Users\611593250\AppData\Local\Programs\Python\Python36-32\lib\site-packages\neo4j\v1\api.py", line 124, in driver
return driver_class(uri, **config)
File "C:\Users\611593250\AppData\Local\Programs\Python\Python36-32\lib\site-packages\neo4j\v1\direct.py", line 65, in __init__
pool.release(pool.acquire())
File "C:\Users\611593250\AppData\Local\Programs\Python\Python36-32\lib\site-packages\neo4j\v1\direct.py", line 44, in acquire
raise ServiceUnavailable("Cannot acquire connection to {!r}".format(self.address))
neo4j.exceptions.ServiceUnavailable: Cannot acquire connection to Address(host='localhost', port=7687)

请咨询.预先感谢!

推荐答案

在定义如下所示的螺栓URL时,您必须添加螺栓端口:

You have to add your bolt port when defining the bolt url like below:

import os
from json import dumps
from flask import Flask, g, Response, request
from neo4j.v1 import GraphDatabase, basic_auth
app = Flask(__name__, static_url_path='/static/')
password = os.getenv("NEO4J_PASSWORD")
driver = GraphDatabase.driver('bolt://localhost:7687',auth=basic_auth("neo4j", password))
print driver

希望这会有所帮助!

这篇关于使用Neo4j驱动程序进行python服务不可用错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆