{"id":2264,"library":"roboflow","title":"Roboflow Python SDK","description":"The Roboflow Python package (version 1.3.1) is the official SDK for interacting with the Roboflow API, enabling programmatic access for tasks such as dataset management, image upload, model training, and inference. It is actively developed, with recent updates including a comprehensive rewrite of the command-line interface and enhanced capabilities for workspace-level asset management.","status":"active","version":"1.3.1","language":"python","source_language":"en","source_url":"https://github.com/roboflow-ai/roboflow-python","tags":["computer vision","machine learning","API client","object detection","image classification","segmentation","dataset management"],"install":[{"cmd":"pip install roboflow","lang":"bash","label":"Install Roboflow"}],"dependencies":[],"imports":[{"symbol":"Roboflow","correct":"from roboflow import Roboflow"}],"quickstart":{"code":"import os\nfrom roboflow import Roboflow\n\n# Ensure your Roboflow API key is set as an environment variable (recommended)\n# os.environ[\"ROBOFLOW_API_KEY\"] = \"YOUR_API_KEY\"\n\n# Initialize Roboflow with your API key\n# Replace 'YOUR_ROBOFLOW_API_KEY' with os.environ.get(\"ROBOFLOW_API_KEY\", \"\") for production\nrf = Roboflow(api_key=os.environ.get(\"ROBOFLOW_API_KEY\", \"\"))\n\n# Example: Get a workspace (replace 'your-workspace-id' with your actual workspace ID)\n# You can often omit the ID if you only have one workspace associated with your API key\ntry:\n    workspace = rf.workspace(\"your-workspace-id\") \n    print(f\"Connected to workspace: {workspace.name}\")\nexcept Exception as e:\n    print(f\"Could not connect to workspace: {e}. Check your API key and workspace ID.\")\n\n# Example: List projects in the workspace\n# if 'workspace' in locals():\n#     projects = workspace.projects()\n#     print(f\"Projects in workspace: {[p.name for p in projects]}\")","lang":"python","description":"Initializes the Roboflow client and demonstrates connecting to a workspace. It's recommended to store your API key in an environment variable for security."},"warnings":[{"fix":"Review the updated Roboflow CLI documentation for the new command structure and output formats. Adapt any scripts or automation workflows that relied on the older CLI behavior.","message":"The v1.3.1 release introduced a complete rewrite of the Roboflow CLI. Users who programmatically invoked CLI commands (e.g., via `subprocess`) will find command structures, argument patterns (`noun verb`), and output formats (e.g., `--json` output) have fundamentally changed. While the Python SDK's core programmatic interface (`roboflow.Roboflow` class) remains stable, direct CLI interaction patterns are now significantly different.","severity":"breaking","affected_versions":">=1.3.1"},{"fix":"Upgrade your Python environment to 3.10 or newer if you need to process HEIF images with the Roboflow SDK. Alternatively, avoid HEIF images on Python 3.9.","message":"When working with HEIF (.heic/.heif) image formats, users on Python 3.9 might encounter issues due to a dependency (`pi_heif`) dropping support for Python 3.9 around Roboflow v1.2.13. This is a dependency-related incompatibility rather than a core Roboflow SDK issue.","severity":"gotcha","affected_versions":">=1.2.13 (when using Python 3.9 for HEIF processing)"},{"fix":"Set your `ROBOFLOW_API_KEY` as an environment variable. When initializing, use `rf = Roboflow(api_key=os.environ.get(\"ROBOFLOW_API_KEY\", \"\"))` to safely retrieve it.","message":"For security and best practice, your Roboflow API key should always be loaded from environment variables (e.g., `os.environ[\"ROBOFLOW_API_KEY\"]`) rather than being hardcoded directly into your scripts. Hardcoding keys can lead to security vulnerabilities if your code is exposed.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'1.3.1':9 'access':22 'activ':37 'api':19,65 'asset':59 'capabl':54 'classif':70 'client':66 'command':49 'command-lin':48 'comprehens':44 'comput':61 'dataset':27,72 'detect':68 'develop':38 'enabl':20 'enhanc':53 'imag':29,69 'includ':42 'infer':34 'interact':15 'interfac':51 'learn':64 'level':58 'line':50 'machin':63 'manag':28,60,73 'model':31 'object':67 'offici':12 'packag':7 'programmat':21 'python':2,6 'recent':40 'rewrit':45 'roboflow':1,5,18 'sdk':3,13 'segment':71 'task':24 'train':32 'updat':41 'upload':30 'version':8 'vision':62 'workspac':57 'workspace-level':56","created_at":"2026-04-09T18:50:32.260395+00:00","updated_at":"2026-04-17T15:05:35.247562+00:00","problems":[{"fix":"pip install roboflow","cause":"The `roboflow` package has not been installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'roboflow'"},{"fix":"Obtain a valid API key from your Roboflow workspace settings and ensure it is passed correctly during initialization, e.g., `rf = Roboflow(api_key='YOUR_API_KEY')`.","cause":"The provided Roboflow API key is incorrect, expired, or lacks the necessary permissions for the requested action.","error":"roboflow.core.roboflow_error.RoboflowError: Authentication failed. Please check your API key."},{"fix":"Verify the exact workspace name and project name from your Roboflow account dashboard and ensure they match your code.","cause":"The specified workspace name or project name provided to `rf.workspace.project()` does not exist or is misspelled.","error":"Exception: Project '<workspace_name>/<project_name>' not found in workspace."},{"fix":"Ensure the input image is valid (correct path, format, not corrupted), the model is correctly loaded and initialized, and all necessary dependencies (e.g., `pip install opencv-python`) are installed.","cause":"This general error indicates an issue during the prediction process, often due to an invalid input image, an uninitialized model, or missing dependencies like `opencv-python`.","error":"roboflow.core.roboflow_error.RoboflowError: There was an error while predicting, please check your image and model settings."},{"fix":"Call `roboflow.login(api_key=\"YOUR_API_KEY\")` with a valid API key, or ensure the `ROBOFLOW_API_KEY` environment variable is correctly set before importing `roboflow`.","cause":"Roboflow attempted an API operation that requires authentication, but a successful login session was not established or has expired.","error":"roboflow.core.exceptions.RoboflowError: You must be logged in to Roboflow to perform this action."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.4.1","cli_name":"roboflow","cli_version":"1.3.8","type":"library","homepage":"https://roboflow.com","github":"https://github.com/roboflow-ai/roboflow-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/roboflow/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","data","aws"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}