{"id":5074,"library":"supervisely","title":"Supervisely Python SDK","description":"Supervisely SDK for Python (pypi-slug: supervisely) provides Python wrappers to programmatically interact with the Supervisely computer vision platform. It simplifies tasks like data management, annotation, model training, and deployment. The library is actively maintained with very frequent releases, often daily or weekly, reflecting continuous development and bug fixes.","status":"active","version":"6.73.556","language":"en","source_language":"en","source_url":"https://github.com/supervisely/supervisely","tags":["computer vision","annotation","machine learning","data management","sdk","api"],"install":[{"cmd":"pip install supervisely","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required Python version.","package":"python","optional":false}],"imports":[{"note":"The `supervisely_lib` package was used in older versions but is now deprecated. Always use `import supervisely as sly`.","wrong":"import supervisely_lib as sly","symbol":"Api","correct":"import supervisely as sly\napi = sly.Api.from_env()"},{"note":"Many core classes are nested within submodules. Refer to the SDK documentation for specific import paths.","symbol":"Project, Dataset, ImageInfo","correct":"from supervisely.project.project import Project\nfrom supervisely.project.dataset import Dataset\nfrom supervisely.api.image_api import ImageInfo"}],"quickstart":{"code":"import os\nimport supervisely as sly\n\n# It is highly recommended to set SERVER_ADDRESS and API_TOKEN as environment variables.\n# For Community Edition, SERVER_ADDRESS is typically 'https://app.supervisely.com'\n# For Enterprise Edition, use your custom instance address.\nSERVER_ADDRESS = os.environ.get('SERVER_ADDRESS', 'https://app.supervisely.com')\nAPI_TOKEN = os.environ.get('API_TOKEN', 'YOUR_SUPERVISELY_API_TOKEN_HERE') # Replace with your actual token or ensure env var is set\n\n# Initialize API client from environment variables (recommended)\n# For local development, you might use a .env file loaded with dotenv.\n# See: https://developer.supervisely.com/getting-started/basics-of-authentication\ntry:\n    api = sly.Api(server_address=SERVER_ADDRESS, token=API_TOKEN)\n    \n    # Test authentication by fetching teams\n    my_teams = api.team.get_list()\n    print(f\"Successfully connected to Supervisely. You are a member of {len(my_teams)} team(s).\")\n    \n    if my_teams:\n        team = my_teams[0]\n        print(f\"First team: {team.name} (ID: {team.id})\")\n        workspaces = api.workspace.get_list(team.id)\n        if workspaces:\n            print(f\"First workspace in team '{team.name}': {workspaces[0].name} (ID: {workspaces[0].id})\")\n        else:\n            print(f\"No workspaces found in team '{team.name}'.\")\n    else:\n        print(\"No teams found for the provided API token. Please check your credentials and permissions.\")\n\nexcept Exception as e:\n    print(f\"Error connecting to Supervisely API: {e}\")\n    print(\"Please ensure SERVER_ADDRESS and API_TOKEN environment variables are correctly set.\")","lang":"python","description":"This quickstart demonstrates how to establish an API connection to the Supervisely platform using recommended authentication practices via environment variables and verifies the connection by listing available teams. For production, always use environment variables for secrets."},"warnings":[{"fix":"Refer to the Supervisely Developer Portal's 'App Compatibility' or 'Installation' section to ensure your SDK version is compatible with your Supervisely instance. It's recommended to keep both updated.","message":"Supervisely SDK versions are tied to the Supervisely instance version. Using an incompatible SDK version with your platform instance can lead to unexpected errors or missing functionality.","severity":"breaking","affected_versions":"All versions"},{"fix":"Always use environment variables (`os.environ`) or `.env` files (loaded with `python-dotenv`) to store `API_TOKEN` and `SERVER_ADDRESS`, and initialize the API client with `sly.Api.from_env()`.","message":"Directly embedding API tokens in your source code (`sly.Api(token='...')`) is highly discouraged for security reasons, especially in production environments. While convenient for quick tests, it exposes sensitive credentials.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use `import supervisely as sly` and access sub-modules directly from `sly` (e.g., `sly.api.project_api`). Refer to the latest SDK documentation for correct import paths.","message":"The `supervisely_lib` package was an earlier module structure. Direct imports from `supervisely_lib` are now deprecated and may cause `ModuleNotFoundError` or lead to outdated behavior in recent SDK versions.","severity":"deprecated","affected_versions":"<=6.x.x (exact version unknown, but prior to current structure)"},{"fix":"Always clone projects for development and testing purposes. The SDK provides methods for cloning projects to ensure your original data remains safe.","message":"When developing scripts or applications that modify data, accidentally altering active projects is a common mistake. This can lead to data loss or corruption in production datasets.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Troubleshoot NVIDIA driver issues, ensure proper Docker runtime configuration (e.g., `nvidia-container-runtime`), and manage memory allocation for GPU-intensive tasks. Rebooting the machine or restarting Docker can often resolve transient NVML errors.","message":"Users deploying Supervisely agents or applications with GPU acceleration might encounter 'Failed to initialize NVML' or 'CUDA Out Of Memory' errors, often related to NVIDIA driver issues or Docker configurations.","severity":"gotcha","affected_versions":"All versions utilizing GPU features"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}