lashex / flask-neo4j

Flask extension providing integration with the Neo4j graph database.
Other
57 stars 16 forks source link

py2neo > 2.0.9 breaks flask-neo4j #12

Open brunoripa opened 8 years ago

brunoripa commented 8 years ago

Apparently the README.rst example does not work if py2neo version is >= 2.0.9. Maybe version should be pinned in setup.py?

It fails by:

flask.ext.Neo4j init_app called
flask.ext.Neo4j gdb trying to connect to DB
Traceback (most recent call last):
  File ".neotest.py", line 15, in <module>
    flask4j = Neo4j(app, graph_indexes).gdb
  File "<snip>/flask-neo4j/flask_neo4j.py", line 153, in gdb
    self.graph_db.legacy.get_or_create_index(i_type, i)
AttributeError: 'Graph' object has no attribute 'legacy'

Issue disappears if i downgrade py2neo at 2.0.9 by doing:

pip install -U py2neo==2.0.9
wgwz commented 7 years ago
 File "/neoflask/neoflask/app.py", line 3, in <module>
   from neoflask.extensions import (
 File "/neoflask/neoflask/extensions.py", line 1, in <module>
   from flask_neo4j import Neo4j
 File "/usr/local/lib/python2.7/site-packages/flask_neo4j.py", line 7, in <module>
   from py2neo.ext import ogm
ImportError: cannot import name ogm

requirements.txt:

Flask==0.11.1 py2neo==3.1.2 Flask-Neo4j==0.5.1

Any plans for compatibility?

wgwz commented 7 years ago

@lashex I think the issue above might be solved by updating pypi. This was not present: https://github.com/lashex/flask-neo4j/commit/16d4628e4456a652869d4331b428f3e150a9b0d7

lashex commented 7 years ago

Sorry for my lag. I accepted the pull request that seems to have fixed this. @brunoripa can you confirm the issue has resolved for you?

brunoripa commented 7 years ago

Sorry for the huge delay.

Still occurs for me. Environment:

Flask==0.11.1
Flask-Neo4j==0.5.1
py2neo==3.1.2

Example code is the same of the README.

Have the same import error

Antwnina commented 7 years ago

python dracula.py dracula.py:2: ExtDeprecationWarning: Importing flask.ext.neo4j is deprecated, use flask_neo4j instead. from flask.ext.neo4j import Neo4j Traceback (most recent call last): File "dracula.py", line 2, in from flask.ext.neo4j import Neo4j File "/usr/local/lib/python2.7/dist-packages/flask/exthook.py", line 96, in load_module reraise(exc_type, exc_value, tb.tb_next) File "/usr/local/lib/python2.7/dist-packages/Flask_Neo4j-0.5.1-py2.7.egg/flask_neo4j.py", line 7, in from py2neo.ext import ogm ImportError: cannot import name ogm

Also i went to the site you provided "https://github.com/lashex/flask-neo4j/commit/16d4628e4456a652869d4331b428f3e150a9b0d7" my code node is from flask import Flask from flask.ext.neo4j import Neo4j from py2neo import Node,Relationship

Configuration

GRAPH_DATABASE='http://localhost:7474/db/data/'

GRAPH_USER = 'neo4j'

GRAPH_PASSWORD = '123'

GRAPH_DATABASE='http://neo4j:123@localhost:7474'

------my------

from flask import Flask, render_template, request, url_for, session

import re

!/usr/bin/env python

import re

from py2neo import Graph

from py2neo import Node, Relationship

graph = Graph("http://neo4j:123@localhost:7474")

------end my------

import time import logging from py2neo import authenticate, Graph,Node

from py2neo.ext import ogm

Support for py2neo v3

try: from py2neo import ogm except ImportError: from py2neo.ext import ogm

log = logging.getLogger('flask.neo4j') logging.basicConfig()

from py2neo.packages.httpstream.http import SocketError

Support for py2neo v3

try: from py2neo import ogm except ImportError: from py2neo.ext import ogm

log = logging.getLogger('flask.neo4j') logging.basicConfig()

app = Flask(name) app.config.from_object(name) graph_indexes = {'Species': Node} flask4j = Neo4j(app, graph_indexes).gdb print flask4j.neo4j_version nosferatu = Node('species',full_name='Dracula nosferatu',species_name='nosferatu') genus = Node('genus',name='Dracula') nosferatu_memberof_genus = Relationship(nosferatu,'Member-of',genus) flask4j.create(nosferatu_memberof_genus)

which all results in a graph that looks like:

(species)-[:MEMBER_OF]->(genus)

-->and still not working... any idea?

geraldmc commented 7 years ago

Instead of 'pip install flask-neo4j' you should install directly from Github. Seems like the current package on PyPi is old.

This worked for me:

pip uninstall flask-neo4j pip install -e git+https://github.com/lashex/flask-neo4j.git#egg=flask-neo4j

Also, this:

from flask import Flask from flask.ext.neo4j import Neo4j from py2neo import Node,Relationship

Should now be this:

from flask import Flask from flask_neo4j import Neo4j from py2neo import Node,Relationship