{"id":24290,"library":"py2neo","title":"py2neo","description":"Py2neo is a client library and toolkit for working with Neo4j from Python applications. As of version 2021.2.4, it supports Neo4j 4.x and uses the Bolt protocol. Development has slowed; users are encouraged to migrate to the official neo4j driver for newer Neo4j versions.","status":"maintenance","version":"2021.2.4","language":"python","source_language":"en","source_url":"https://github.com/py2neo-org/py2neo","tags":["neo4j","graph-database","cypher","bolt","database-client"],"install":[{"cmd":"pip install py2neo","lang":"bash","label":"PyPI install"}],"dependencies":[{"reason":"Bolt protocol driver for Neo4j, required at runtime","package":"neobolt","optional":false},{"reason":"DateTime handling for Neo4j temporal types","package":"neotime","optional":false},{"reason":"HTTP client for REST API calls","package":"urllib3","optional":false}],"imports":[{"note":"In older versions (pre-2021), Graph was under py2neo.database. Use py2neo.Graph directly.","wrong":"from py2neo.database import Graph","symbol":"Graph","correct":"from py2neo import Graph"},{"note":"Common mistake: from py2neo.data import Node (deprecated).","symbol":"Node","correct":"from py2neo import Node"},{"note":"Same as Node; import from top-level py2neo.","symbol":"Relationship","correct":"from py2neo import Relationship"},{"note":"Available from py2neo directly.","symbol":"NodeMatcher","correct":"from py2neo import NodeMatcher"}],"quickstart":{"code":"from py2neo import Graph, Node, Relationship\n\n# Connect to Neo4j (adjust URI/user/password)\ngraph = Graph(\"bolt://localhost:7687\", auth=(\"neo4j\", \"password\"))\n\n# Create a node\nalice = Node(\"Person\", name=\"Alice\")\ngraph.create(alice)\n\n# Create another node and relationship\nbob = Node(\"Person\", name=\"Bob\")\nknows = Relationship(alice, \"KNOWS\", bob)\ngraph.create(knows)\n\n# Query back\nresults = graph.run(\"MATCH (a:Person)-[:KNOWS]->(b:Person) RETURN a.name, b.name\").data()\nprint(results)","lang":"python","description":"Connect to Neo4j, create nodes and a relationship, then run a Cypher query."},"warnings":[{"fix":"Use `pip install neo4j` and migrate to the official driver.","message":"py2neo is no longer actively developed. The official neo4j Python driver (neo4j) is recommended for new projects, especially for Neo4j 5.x.","severity":"deprecated","affected_versions":">=2021.0.0"},{"fix":"Update connection strings from http:// to bolt:// and ensure Neo4j is 4.x+.","message":"Version 2021.0 dropped support for Neo4j 3.x and removed the HTTP API for Bolt-only. Existing code using REST endpoints will break.","severity":"breaking","affected_versions":">=2021.0.0"},{"fix":"Use `Graph('bolt://localhost:7687', auth=(user, pass))` instead of `Graph(host='localhost', ...)`.","message":"The `Graph` constructor no longer accepts keyword arguments for host, port, etc. It expects a full URI string.","severity":"gotcha","affected_versions":">=2021.0.0"},{"fix":"Use `matcher.match('Person', name='Alice').first()` and check if result is not None.","message":"Subgraph matching with `NodeMatcher` may return `None` if no match found; always check result before accessing attributes.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `pip install py2neo --upgrade` and use `from py2neo import Graph`.","cause":"Incorrect import in older style; or py2neo not installed correctly.","error":"AttributeError: module 'py2neo' has no attribute 'Graph'"},{"fix":"Provide a valid (username, password) tuple: `Graph('bolt://localhost:7687', auth=('neo4j', 'yourpassword'))`.","cause":"Wrong credentials or missing auth tuple in Graph constructor.","error":"py2neo.database.ClientError: The client is unauthorized due to authentication failure."},{"fix":"Ensure Neo4j is started and reachable at the specified URI. Try `bolt://localhost:7687`.","cause":"Neo4j not running, or wrong host/port.","error":"OSError: [Errno 111] Connection refused"},{"fix":"Change to `bolt://` in the URI. Older versions accept `http://` but are deprecated.","cause":"Using 'http' URI with a Bolt-only version of py2neo (2021+).","error":"ValueError: The protocol specified is not supported."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}