{"id":7535,"library":"pyanzo","title":"PyAnzo","description":"PyAnzo is a Python library for programmatic interaction with Anzo, a knowledge graph platform developed by Cambridge Semantics. Anzo enables the ingestion, transformation, storage, exploration, and analysis of diverse data types using open W3C standards such as Web Ontology Language (OWL), Resource Description Framework (RDF), and SPARQL. The library is currently at version 3.3.12 and receives regular, primarily patch-level, updates.","status":"active","version":"3.3.12","language":"en","source_language":"en","source_url":null,"tags":["anzo","sparql","rdf","knowledge-graph","semantic-web"],"install":[{"cmd":"pip install pyanzo","lang":"bash","label":"Install PyAnzo"}],"dependencies":[{"reason":"Runtime environment","package":"python","version":">=3.5","optional":false}],"imports":[{"symbol":"AnzoClient","correct":"from pyanzo import AnzoClient"}],"quickstart":{"code":"import os\nfrom pyanzo import AnzoClient\n\nANZO_HOST = os.environ.get('ANZO_HOST', 'your_anzo_server.com')\nANZO_PORT = int(os.environ.get('ANZO_PORT', '443'))\nANZO_USER = os.environ.get('ANZO_USER', 'your_username')\nANZO_PASS = os.environ.get('ANZO_PASS', 'your_password')\nANZO_GRAPH MART_URI = os.environ.get('ANZO_GRAPH MART_URI', 'http://cambridgesemantics.com/anzo/graphmart/example')\n\n# Basic SPARQL query example\nSPARQL_QUERY = \"\"\"\nSELECT ?s ?p ?o WHERE {\n  ?s ?p ?o .\n}\nLIMIT 10\n\"\"\"\n\ntry:\n    client = AnzoClient(ANZO_HOST, ANZO_USER, ANZO_PASS, anzo_port=ANZO_PORT)\n    print(f\"Successfully connected to Anzo at {ANZO_HOST}:{ANZO_PORT}\")\n\n    print(f\"Querying graphmart: {ANZO_GRAPH MART_URI}\")\n    results = client.query_graphmart_SELECT(ANZO_GRAPH MART_URI, SPARQL_QUERY)\n\n    print(\"Query Results:\")\n    for row in results:\n        print(row)\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to establish a connection to an Anzo server using `AnzoClient` and execute a simple SPARQL SELECT query against a specified graphmart. Ensure you set the `ANZO_HOST`, `ANZO_PORT`, `ANZO_USER`, `ANZO_PASS`, and `ANZO_GRAPH MART_URI` environment variables for a successful connection."},"warnings":[{"fix":"Verify `ANZO_HOST`, `ANZO_PORT`, `ANZO_USER`, and `ANZO_PASS` (or equivalent configuration) are correct and that network firewalls allow access to the Anzo server.","message":"Anzo server connectivity issues are common. Ensure the correct host, port, and credentials are provided, and that the Anzo server is reachable from where PyAnzo is executed. Default ports might vary (e.g., 443 for HTTPS, 80 for HTTP).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Confirm the graphmart URI is correct and that the target graphmart is activated within the Anzo environment. Use Anzo's administrative tools to list available graphmarts.","message":"Incorrect Graphmart URIs or non-activated graphmarts will lead to query failures. The URI must precisely match an existing and activated graphmart on the Anzo server.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Validate SPARQL query syntax using a SPARQL editor or Anzo's query validation tools before executing programmatically. Ensure all prefixes are defined if used.","message":"SPARQL queries are case-insensitive for keywords but sensitive for URIs and literals. Syntax errors in SPARQL can cause query failures.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Check the `ANZO_HOST` and `ANZO_PORT` values. Ping the server's hostname/IP from the client machine. Verify firewall rules. Confirm the Anzo server is running and accessible.","cause":"The PyAnzo client could not establish a network connection to the specified Anzo server. This might be due to an incorrect hostname/IP, wrong port, firewall blocking the connection, or the Anzo server not running or being inaccessible.","error":"AnzoClientException: Could not connect to Anzo server at [hostname]:[port]"},{"fix":"Double-check the `ANZO_USER` and `ANZO_PASS` values. Ensure the user exists and has the required permissions on the Anzo server.","cause":"The username or password provided to `AnzoClient` is incorrect, or the user lacks the necessary permissions to connect or perform actions.","error":"AnzoClientException: Invalid credentials provided for Anzo server."},{"fix":"Verify the `ANZO_GRAPH MART_URI` is correct by checking Anzo's administrative interface. Ensure the graphmart is activated and has successfully loaded its data.","cause":"The specified graphmart URI does not exist on the connected Anzo server, or it has not been activated and made ready for querying.","error":"AnzoClientException: Graphmart [graphmart_uri] not found or not activated."}]}