ModuleNotFoundError: No module named 'py2neo.cypher.error'

Hello everyone.

I'm trying to handle the Constraint Validation exceptions into my Python code.
However I'm facing ModuleNotFoundError: No module named 'py2neo.cypher.error' error even after install py2neo==4.1.3.

My code:
from py2neo import Graph
from py2neo.cypher.error.schema import ConstraintViolation
import traceback
except ConstraintViolation as e:

Does anyone already faced this?
How can I solve that?

Many thanks.

This code snipped seems to be written for an older version of py2neo. I'm not an export for py2neo but I think the current approach to this goes something along those lines:

from py2neo import Neo4jError

except Neo4jError as e:
    if e.code == "Neo.ClientError.Schema.ConstraintViolation":

Haven't tested it. So maybe it needs some slight adjustment.

Those links might be helpful: