{"id":1116,"library":"openxlab","title":"OpenXLab Python SDK","description":"OpenXLab is a Python library providing tools to interact with the OpenXLab platform, focusing on managing datasets and models. It includes a command-line interface (CLI) and a Python SDK to programmatically access platform features such as dataset information, upload, and download. The library is currently at version 0.1.3 and appears to have a regular release cadence, with updates often reflecting platform-level changes within the broader OpenXLab ecosystem.","status":"active","version":"0.1.3","language":"python","source_language":"en","source_url":"https://github.com/OpenDataLab/","tags":["machine-learning","ai","datasets","data-management","cloud-platform","utilities"],"install":[{"cmd":"pip install openxlab","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"HTTP communication with OpenXLab platform.","package":"requests"},{"reason":"Progress bars for file transfers.","package":"tqdm"},{"reason":"Interacting with object storage service for data operations.","package":"oss2"},{"reason":"Build and distribution utility; specific versions have caused conflicts.","package":"setuptools","optional":true}],"imports":[{"symbol":"get","correct":"from openxlab.dataset import get"},{"symbol":"upload_folder","correct":"from openxlab.dataset import upload_folder"},{"note":"The token utility is nested within `xlab.handler.user_token`.","wrong":"from openxlab.token import get_jwt","symbol":"get_jwt","correct":"from openxlab.xlab.handler.user_token import get_jwt"}],"quickstart":{"code":"import os\nfrom openxlab.xlab.handler.user_token import get_jwt\nfrom openxlab.dataset import get\n\n# Set your Access Key and Secret Key as environment variables\n# These can be obtained from your OpenXLab user center.\n# For example: export OPENXLAB_AK=\"YOUR_AK_HERE\"\n# For example: export OPENXLAB_SK=\"YOUR_SK_HERE\"\nak = os.environ.get('OPENXLAB_AK', 'YOUR_AK_HERE')\nsk = os.environ.get('OPENXLAB_SK', 'YOUR_SK_HERE')\n\nif ak == 'YOUR_AK_HERE' or sk == 'YOUR_SK_HERE':\n    print(\"Please set OPENXLAB_AK and OPENXLAB_SK environment variables or replace placeholders.\")\n    # Attempt to use CLI config if env vars are not set for demonstration purposes\n    # In a real scenario, user would run 'openxlab config' or set env vars.\n    # For programmatic access, env vars are preferred.\nelse:\n    try:\n        # Authenticate and get a JWT token\n        token = get_jwt(ak=ak, sk=sk)\n        print(f\"Successfully obtained JWT token (first 10 chars): {token[:10]}...\")\n\n        # Example: Get (download) a public dataset\n        # Replace 'OpenDataLab/MNIST' with a valid dataset repository and adjust target_path\n        # Ensure the target_path exists or can be created.\n        dataset_repo_name = 'OpenDataLab/MNIST'\n        target_download_path = './MNIST_dataset'\n        print(f\"\\nAttempting to download dataset: {dataset_repo_name} to {target_download_path}\")\n        \n        # Create a dummy directory for download if it doesn't exist\n        os.makedirs(target_download_path, exist_ok=True)\n\n        # Note: The 'get' function might automatically use configured AK/SK,\n        # but explicit authentication often precedes other SDK calls.\n        get(dataset_repo=dataset_repo_name, target_path=target_download_path)\n        print(f\"Dataset '{dataset_repo_name}' downloaded to '{target_download_path}' successfully.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        print(\"Ensure your AK/SK are correct and you have network access to OpenXLab.\")\n","lang":"python","description":"This quickstart demonstrates how to authenticate with OpenXLab using environment variables for Access Key (AK) and Secret Key (SK), and then how to use the `openxlab.dataset.get` function to download a public dataset. Replace 'YOUR_AK_HERE' and 'YOUR_SK_HERE' with your actual credentials, or ideally, set them as environment variables (OPENXLAB_AK, OPENXLAB_SK). The example attempts to download the 'OpenDataLab/MNIST' dataset, which is a common public dataset."},"warnings":[{"fix":"While potentially resolved in newer versions, if you encounter `setuptools` conflicts, try isolating `openxlab` in a virtual environment or explicitly pinning `setuptools` to a compatible version as a temporary workaround. Check release notes for explicit dependency updates.","message":"Older versions of `openxlab` (e.g., 0.0.37) have been reported to have `setuptools` dependency conflicts (requiring `~=60.2.0` while other packages might need newer versions).","severity":"gotcha","affected_versions":"<0.1.0"},{"fix":"Always ensure your `OPENXLAB_AK` and `OPENXLAB_SK` environment variables are correctly set and valid, or that `openxlab config` has been run. Verify network connectivity to the OpenXLab API endpoints. For programmatic access, using environment variables is the most recommended and secure approach.","message":"Authentication (Access Key and Secret Key) is crucial. If not configured via `openxlab config`, `~/.openxlab/config.json`, or environment variables (`OPENXLAB_AK`, `OPENXLAB_SK`), API calls will fail. Direct `openxlab.login` or SDK calls can also fail with 503 Server Error if the backend service is unavailable.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer to the official OpenXLab documentation (浦源-文档中心) for the most accurate and up-to-date SDK usage patterns and import paths. Confirm you are installing the correct `openxlab` package (`pip install openxlab`) if interacting with the OpenXLab platform.","message":"The `openxlab` PyPI package and its GitHub presence can be confusing due to similar names with other projects (e.g., `OpenXLA`, `openclaw`) and its integration within a broader OpenXLab/OpenDataLab ecosystem. The primary source for the Python SDK functionality for datasets and models resides within modules imported from `openxlab`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.1.3':53 'access':37 'ai':78 'appear':55 'broader':72 'cadenc':61 'chang':69 'cli':30 'cloud':84 'cloud-platform':83 'command':27 'command-lin':26 'current':50 'data':81 'data-manag':80 'dataset':20,42,79 'download':46 'ecosystem':74 'featur':39 'focus':17 'includ':24 'inform':43 'interact':12 'interfac':29 'learn':77 'level':68 'librari':8,48 'line':28 'machin':76 'machine-learn':75 'manag':19,82 'model':22 'often':64 'openxlab':1,4,15,73 'platform':16,38,67,85 'platform-level':66 'programmat':36 'provid':9 'python':2,7,33 'reflect':65 'regular':59 'releas':60 'sdk':3,34 'tool':10 'updat':63 'upload':44 'util':86 'version':52 'within':70","created_at":"2026-04-05T13:06:23.271815+00:00","updated_at":"2026-04-16T17:47:05.961543+00:00","problems":[{"fix":"Create a new virtual environment and install `openxlab` first, or downgrade/upgrade `setuptools` to a compatible version using `pip install setuptools==A.B.C` (replacing A.B.C with the version required by openxlab) before installing other conflicting packages.","cause":"The `openxlab` library requires a specific version range of `setuptools` which conflicts with another package already installed in your environment, preventing successful installation or operation.","error":"ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. openxlab X.Y.Z requires setuptools~=A.B.C, but you have setuptools D.E.F which is incompatible."},{"fix":"Set up your authentication credentials by running the OpenXLab CLI configuration command: `python -m openxlab.cli config` and follow the prompts to enter your AK and SK. Alternatively, you can create a `config.json` file in `~/.openxlab/` or set `OPENXLAB_AK` and `OPENXLAB_SK` environment variables.","cause":"The OpenXLab SDK cannot find the necessary Access Key (AK) and Secret Access Key (SK) configuration to authenticate, which are required to obtain a token for API interactions.","error":"ValueError(\"Local config must not be empty before get token via api. Please use the 'openxlab config' command to set the config\")"},{"fix":"Re-authenticate using `openxlab login --relogin` in the CLI or re-run `python -m openxlab.cli config` to ensure your credentials are up-to-date and correctly configured. Verify that your Access Key and Secret Access Key are correct and have the necessary permissions.","cause":"Your OpenXLab session has expired, or the provided authentication credentials (AK/SK or token) are invalid or lack the necessary permissions for the requested operation.","error":"401: {\"msg\":\"login required\"}"},{"fix":"Ensure `openxlab` is correctly installed via `pip install openxlab`. If the issue persists, explicitly run the CLI using `python -m openxlab.cli` or verify that the directory where pip installs scripts (e.g., `~/.local/bin` on Linux or Python's `Scripts` directory on Windows) is included in your system's PATH. You may need to restart your terminal after installation.","cause":"The `openxlab` command-line interface executable is not found in your system's PATH environment variable, or the installation was incomplete.","error":"openxlab: command not found"},{"fix":"Check your internet connection and ensure the dataset repository name is correct (e.g., `username/repo_name`). You can also try again later as it might be a temporary server issue. If the problem persists, check the OpenXLab platform for the dataset's availability and permissions.","cause":"An error occurred during the process of downloading a dataset, which could be due to network issues, an incorrect dataset repository name, or server-side problems.","error":"download dataset error"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.1.3","cli_name":"openxlab","cli_version":"usage: openxlab [-h] {version,demo,config,dataset,model,login,token,help} ...","type":"library","homepage":"https://openxlab.org.cn","github":"https://github.com/xxx/xxxx","docs":null,"changelog":null,"pypi":"https://pypi.org/project/openxlab/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}