hf-cloud-python-env-setup
できること
このスキルは、機械学習のデプロイとAWSのスクリプトのために、隔離されたPython環境を準備します。Pythonのバージョンの誤りや古いライブラリが原因のエラーに遭遇している人向けです。
使う場面
- ✓SageMakerのデプロイ、学習ジョブ、AWSの自動化のためにPythonコードを実行するとき。
- ✓エージェントがパッケージをインストールしようとしている、またはboto3を呼び出そうとしているとき。
- ✓環境を設定するようエージェントに依頼したとき。
スキルのリンク
https://github.com/huggingface/skills/blob/main/skills/hf-cloud-python-env-setup/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“SageMakerのデプロイスクリプトを実行できるように、クリーンなPython環境を設定してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIは、対応するPythonのバージョン(3.10から3.12)で別の環境を作り、必要なパッケージの最新版をインストールします。その後、インストールされたバージョンを確実な方法で確認します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Python Environment Setup for SageMaker
Most SageMaker deployment failures that look like AWS problems are actually Python environment problems: wrong Python version, broken dependency resolution, stale SDK that doesn't know about a current API. This skill makes env setup boring and correct.
Core rules
- Never use the system Python. Always work inside an isolated environment.
- Pin the Python version, not the package versions. Use 3.10, 3.11, or 3.12. Avoid 3.13+ — ML libraries lag on wheel availability and dependency resolution breaks in confusing ways.
- Install the latest of each package. Don't defensively pin
boto3orawscli. Newer ones have current API surfaces and security fixes. Only pin if the user explicitly requires a specific version. - Check installed versions correctly. Use
importlib.metadata.version("package-name"), nevermodule.__version__. The latter is inconsistent across packages. - The bundled scripts use
boto3directly. The SageMaker Python SDK is a valid alternative — see "boto3 vs the SageMaker SDK" below.
boto3 vs the SageMaker SDK
The bundled deploy scripts (deploy.py, deploy_async.py, teardown.py) use boto3 directly and read image URIs from AWS's published Deep Learning Containers catalog. That fits this workflow's explicit-stages design — each skill produces a concrete value (region, role ARN, image URI) that the next one consumes — and boto3 is the stable underlying API client.
The SageMaker Python SDK (v3) is fine to use when the user prefers it or their project already does. Since PR #5960 (June 2026), ModelBuilder auto-routes HuggingFace models to the current containers (text-generation → HuggingFace vLLM, multimodal → vLLM-Omni, embeddings → TEI). Don't avoid the SDK over stale-image or wrong-container concerns — that routing is fixed.
Two specific SDK cases that still need care:
- Generative rerankers: the SDK routes the
text-rankingtask to TEI unconditionally, which is wrong for causal-LM rerankers like Qwen3-Reranker — those need vLLM (seehf-cloud-serving-image-selection). Pass the container explicitly for these models. - SSO assumed-role credentials: v3 has had credential-resolution regressions in
ModelTrainer/FrameworkProcessorunder SSO profiles. If SDK calls fail with credential errors whileaws sts get-caller-identitysucceeds in the same shell, suspect this rather than your AWS config.
If you use the SDK, install it into the isolated env like everything else (.venv/bin/python -m pip install sagemaker). The bundled scripts don't require it.
How to set up
The fastest path is the bundled script — it's Python, so it runs the same on Windows, macOS, and Linux:
python3 scripts/setup_env.py # macOS / Linux
python scripts/setup_env.py # Windows (PowerShell / cmd)
This script detects uv and uses it if available (faster), falls back to the stdlib venv module, creates .venv/ with Python 3.12 (override: python3 setup_env.py .venv 3.11), refuses unsupported Python versions, installs from the bundled requirements.txt, and is idempotent. It also prints the correct interpreter path for the host OS (see below).
Manual equivalent:
# Preferred: uv
uv venv --python 3.12 .venv
uv pip install --python .venv/bin/python --upgrade boto3 awscli # Windows: .venv\Scripts\python.exe
# Fallback: stdlib venv
python3.12 -m venv .venv
.venv/bin/python -m pip install --upgrade pip boto3 awscli
After setup, invoke the env's Python explicitly rather than activating the venv. The interpreter path differs by platform:
.venv/bin/python deploy.py # macOS / Linux
.venv\Scripts\python.exe deploy.py # Windows
This works the same in scripts, interactive shells, and agent tool calls. The rest of this skill writes .venv/bin/python for brevity — on Windows substitute .venv\Scripts\python.exe.
Verifying
.venv/bin/python scripts/check_versions.py
Prints versions of boto3, botocore, awscli. Uses importlib.metadata.version() so it works on every package, including ones without __version__. Pass arbitrary names: ... check_versions.py transformers huggingface_hub.
Deployment-specific extras
Default requirements.txt covers SageMaker orchestration. Some deployments need extras (`hu
よくある質問
システムのPythonを使わないのはなぜですか?
このスキルは常に隔離された環境で作業するので、コンピューター上の他のソフトウェアが干渉しません。
パッケージのバージョンは固定しますか?
いいえ。特定のバージョンを頼まれない限り、パッケージの最新版をインストールします。
最新のPythonのバージョンを避けるのはなぜですか?
機械学習のライブラリは、最新のPythonのバージョンへの対応が遅れることがあり、わかりにくいインストールの問題を引き起こすためです。
詳細
作者による元の説明
Set up an isolated Python environment for SageMaker / AWS work, with the right Python version and current boto3. Use this skill whenever Python code will be executed for a SageMaker deployment, training job, or any AWS automation — including when about to run `pip install`, when about to invoke `boto3`, when creating or activating a virtualenv, or when the user asks to "set up the environment". Never use system Python and never `pip install` into it. Always isolate. This skill prevents the most common failure modes: wrong Python version, dependency conflicts, and stale SDKs.
repo: huggingface/skills
人気
- GitHubのスター
- 11k
- ランキング
- #11767
- ライセンス
- Apache-2.0
- 更新日
- 2026/10/30
コメント
- …
このリポジトリの他のスキル
hf-cli
11kエージェントが、Hugging Faceのコマンドラインツールhfでモデル、データセット、Spaces、リポジトリ、ローカルのキャッシュをダウンロード、アップロード、管理できるよう支援します。
hf-cloud-aws-context-discovery
11kエージェントが、クラウドの作業を始める前にAWSのプロファイル、リージョン、アカウントの詳細を見つけ、どのアカウントを使うかを推測しないよう支援します。
hf-cloud-sagemaker-deployment-planner
11kエージェントが、モデルをAmazon SageMakerにデプロイする方法を計画し、リアルタイム、サーバーレス、非同期、バッチのホスティングから、適切な既定値とともに選べるよう支援します。
hf-cloud-sagemaker-iam-preflight
11kエージェントが、デプロイ前に使えるSageMakerの実行ロールがあるかを確認し、確認せずにAWSアカウントに新しい権限を作ることを避けられるよう支援します。
似ているスキル
openclaw-update
394k既存のOpenClaw Gatewayを更新するようエージェントを支援します。インストール方法に合った更新方法を選び、セッションを動かし続けます。
diagnose-gateway
394k設定、チャンネル、ポートを確認して、OpenClaw Gatewayが失敗している理由を、何も変更せずに突き止めるようエージェントを支援します。
crabbox-apps
394k一時的なクラウドマシン上でアプリを開いて実行し、そのビューをチャットのサイドパネルに表示するようエージェントを支援します。