Registry / data / openxlab

openxlab

JSON →
library0.1.3pypypi✓ verified 24d ago

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.

pip install openxlab
INSTALL
IMPORT
SIG · OPENXLAB
O
openxlab
datapythonv0.1.3
Install
8.2s avg
Import
615ms
Disk
75MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.640s · 71.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 8.2s · import 0.590s · 74MB
75MB installed
● package 75MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

get
from openxlab.dataset import get
upload_folder
from openxlab.dataset import upload_folder
get_jwt
from openxlab.xlab.handler.user_token import get_jwt
from openxlab.token import get_jwt
The token utility is nested within `xlab.handler.user_token`.

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.

import os from openxlab.xlab.handler.user_token import get_jwt from openxlab.dataset import get # Set your Access Key and Secret Key as environment variables # These can be obtained from your OpenXLab user center. # For example: export OPENXLAB_AK="YOUR_AK_HERE" # For example: export OPENXLAB_SK="YOUR_SK_HERE" ak = os.environ.get('OPENXLAB_AK', 'YOUR_AK_HERE') sk = os.environ.get('OPENXLAB_SK', 'YOUR_SK_HERE') if ak == 'YOUR_AK_HERE' or sk == 'YOUR_SK_HERE': print("Please set OPENXLAB_AK and OPENXLAB_SK environment variables or replace placeholders.") # Attempt to use CLI config if env vars are not set for demonstration purposes # In a real scenario, user would run 'openxlab config' or set env vars. # For programmatic access, env vars are preferred. else: try: # Authenticate and get a JWT token token = get_jwt(ak=ak, sk=sk) print(f"Successfully obtained JWT token (first 10 chars): {token[:10]}...") # Example: Get (download) a public dataset # Replace 'OpenDataLab/MNIST' with a valid dataset repository and adjust target_path # Ensure the target_path exists or can be created. dataset_repo_name = 'OpenDataLab/MNIST' target_download_path = './MNIST_dataset' print(f"\nAttempting to download dataset: {dataset_repo_name} to {target_download_path}") # Create a dummy directory for download if it doesn't exist os.makedirs(target_download_path, exist_ok=True) # Note: The 'get' function might automatically use configured AK/SK, # but explicit authentication often precedes other SDK calls. get(dataset_repo=dataset_repo_name, target_path=target_download_path) print(f"Dataset '{dataset_repo_name}' downloaded to '{target_download_path}' successfully.") except Exception as e: print(f"An error occurred: {e}") print("Ensure your AK/SK are correct and you have network access to OpenXLab.")
openxlab --version
Debug
Known issues
gotchaOlder 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).
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.
affects: <0.1.0
gotchaAuthentication (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.
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.
affects: All versions
gotchaThe `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`.
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.
affects: All versions
Errors
Common errors & fixes
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.
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.
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.
ValueError("Local config must not be empty before get token via api. Please use the 'openxlab config' command to set the config")
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.
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.
401: {"msg":"login required"}
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.
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.
openxlab: command not found
The `openxlab` command-line interface executable is not found in your system's PATH environment variable, or the installation was incomplete.
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.
download dataset error
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.
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.
Upgrade
Version history
0.1.3latest on PyPI · released Oct 21, 2025
Audit
Dependencies
requestsrequiredHTTP communication with OpenXLab platform.
tqdmrequiredProgress bars for file transfers.
oss2requiredInteracting with object storage service for data operations.
setuptoolsoptionalBuild and distribution utility; specific versions have caused conflicts.
Agent activity
69 hits · last 30 days
node
65
Resources
openxlab — pip install openxlab · libregistry