{"id":7503,"library":"plantuml","title":"Python PlantUML Client","description":"The `plantuml` Python library provides a client to generate PlantUML diagrams from Python code. It can interact with a local PlantUML JAR file (requiring Java) or a remote PlantUML server (including the public one). The current version is 0.3.0, with updates occurring infrequently but the project is actively maintained for compatibility and minor enhancements.","status":"active","version":"0.3.0","language":"en","source_language":"en","source_url":"https://github.com/dougn/python-plantuml/","tags":["UML","diagrams","PlantUML","code-generation"],"install":[{"cmd":"pip install plantuml","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"PlantUML","correct":"from plantuml import PlantUML"}],"quickstart":{"code":"from plantuml import PlantUML\n\n# Initialize PlantUML client.\n# By default, it uses the public server: http://www.plantuml.com/plantuml\n# For a local server, provide the jar_path or custom url:\n# pu = PlantUML(jar_path='/path/to/plantuml.jar')\n# pu = PlantUML(url='http://localhost:8080/plantuml')\npu = PlantUML() # Uses the default public server\n\npuml_code = \"\"\"\n@startuml\nAlice -> Bob: Authentication Request\nBob --> Alice: Authentication Response\nAlice -> Bob: Another authentication Request\nAlice <-- Bob: Another authentication Response\n@enduml\n\"\"\"\n\ntry:\n    # Generate the diagram image data (PNG by default)\n    image_data = pu.processes(puml_code)\n\n    # Define the output filename\n    output_filename = \"quickstart_diagram.png\"\n\n    # Save the image data to a file\n    with open(output_filename, \"wb\") as f:\n        f.write(image_data)\n\n    print(f\"Successfully generated PlantUML diagram to {output_filename}\")\n\nexcept Exception as e:\n    print(f\"An error occurred during diagram generation: {e}\")\n    print(\"Please ensure you have an internet connection if using the default server,\")\n    print(\"or that your local PlantUML setup (Java + JAR) is correct.\")","lang":"python","description":"This quickstart demonstrates how to initialize the PlantUML client and generate a basic PNG diagram using the default public PlantUML server. The generated image data is then saved to a file."},"warnings":[{"fix":"Ensure Java is installed (`java -version`) and `jar_path` points to a valid PlantUML.jar file. Alternatively, use remote generation by specifying a `url` or relying on the default public server.","message":"Local diagram generation (using `jar_path`) requires Java to be installed and accessible in your system's PATH, as well as a downloaded PlantUML JAR file.","severity":"gotcha","affected_versions":"All"},{"fix":"For production or high-volume usage, consider hosting your own PlantUML server and providing its URL to the `PlantUML` constructor: `PlantUML(url='http://your-server:8080/plantuml')`.","message":"The default remote server `http://www.plantuml.com/plantuml` might be subject to rate limits, uptime issues, or network restrictions.","severity":"gotcha","affected_versions":"All"},{"fix":"Verify the `url` parameter. Test connectivity to the PlantUML server URL directly (e.g., in a browser or using `curl`). Ensure no firewalls are blocking the connection.","message":"When using a custom `url` for a remote server, ensure the URL is correct and the PlantUML server is running and accessible from where your Python script is executed.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install a Java Development Kit (JDK) or Java Runtime Environment (JRE) on your system. Ensure the `java` executable is available in your system's PATH environment variable. Verify by running `java -version` in your terminal.","cause":"The `plantuml` library, when configured for local processing via `jar_path`, attempts to execute the `java` command, but Java is not installed or not found in the system's PATH.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'java'"},{"fix":"Check your internet connection. If using a custom `url`, verify the PlantUML server is running and accessible from your machine. If using the default public server, try again later or consider hosting your own PlantUML server.","cause":"This (or similar `ConnectionError`) typically occurs when the PlantUML server specified in the `url` parameter (or the default public server) is unreachable, down, or a network issue (e.g., firewall, proxy) is preventing the connection.","error":"requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))"},{"fix":"Validate your PlantUML code. Use an online PlantUML editor (e.g., `plantuml.com/text`) to paste and preview your code, identifying and fixing any syntax issues before passing it to the `plantuml` library.","cause":"The PlantUML diagram code provided to the `processes()` method contains syntax errors or is malformed, preventing PlantUML from generating a correct diagram.","error":"Diagram output is blank, incomplete, or shows syntax errors within the image."}]}