
Python Environment Setup for SageMaker
FreeEasily configure isolated Python environments for AWS.
Free · Opens the source repo
What Python Environment Setup for SageMaker does
The Python Environment Setup for SageMaker skill simplifies the process of configuring isolated Python environments specifically for AWS SageMaker and related tasks. It addresses common issues that arise from using the system Python, such as dependency conflicts, incorrect Python versions, and outdated SDKs. By ensuring that you always work within an isolated environment, this skill helps prevent deployment failures that are often misattributed to AWS issues rather than Python environment misconfigurations.
This skill provides a bundled script that automates the setup of a Python virtual environment, allowing you to specify the desired Python version and install the latest versions of necessary packages like boto3 and awscli. The script is designed to be cross-platform, running seamlessly on Windows, macOS, and Linux. It also includes checks to ensure that the installed versions of packages are accurate, using the importlib.metadata.version() method to avoid inconsistencies.
For users who prefer the SageMaker Python SDK, the skill supports its usage while emphasizing that the bundled scripts utilize boto3 directly. This approach allows for more explicit control over the deployment process, ensuring that the correct resources are utilized. The skill also includes guidance on common pitfalls, such as issues related to Python version compatibility and package installation errors, making it a reliable choice for developers working with AWS SageMaker.
Overall, this skill is tailored for developers and data scientists who frequently work with AWS SageMaker and require a robust solution for managing Python environments. By streamlining the setup process and enforcing best practices, it enables users to focus more on their machine learning tasks rather than environment configuration.
When to use it
Use this skill whenever you need to set up a Python environment for SageMaker deployments or AWS automation tasks.
When not to use it
This skill may not be suitable if you are not working with AWS services or if you prefer manual environment setup without automation.
What you can build with it
Setting Up for a SageMaker Training Job
Use this skill to create a Python environment tailored for a SageMaker training job, ensuring all dependencies are correctly managed.
Deploying Machine Learning Models
Quickly configure an isolated Python environment for deploying machine learning models on AWS SageMaker without version conflicts.
Automating AWS Tasks
Set up a reliable Python environment for automating various AWS tasks, minimizing the risk of using outdated SDKs.
How to install Python Environment Setup for SageMaker
View source1. Install with the skills CLI
npx skills add huggingface/skills/hf-cloud-python-env-setup --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by huggingfacePython 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 (huggingface_hub for model inspection, transformers for tokenizer validation). Add these to a deployment-specific requirements file in the project, install with the env's Python, don't pin unless there's a reason.
Common pitfalls
Mysterious pip install resolution errors
Almost always Python 3.13+ trying to install packages without wheels yet, or installing into a polluted system Python. Recreate at 3.12: delete .venv and re-run python3 setup_env.py .venv 3.12 (the script recreates the env when the version doesn't match, so you can also just re-run it).
pip install succeeded but the script says "module not found"
You installed into a different interpreter than the one running the script. Always invoke Python explicitly: .venv/bin/python -m pip install ... and .venv/bin/python deploy.py.
Inline python -c "..." one-liners fail in PowerShell
PowerShell's quoting rules mangle nested/escaped quotes in inline Python. Don't debug the quoting — write the snippet to a small .py file and run that. (All bundled helpers are files for exactly this reason.)
boto3 call fails with "unknown parameter"
Your boto3 is older than the API surface. Upgrade with .venv/bin/python -m pip install --upgrade boto3. Don't downgrade the script to match an old version.
sagemaker (the SDK) installed but the bundled scripts fail
The bundled scripts don't use the SDK — they only need boto3/awscli from requirements.txt. Installing sagemaker alongside is harmless, but it doesn't replace the requirements install.
Frequently asked questions about Python Environment Setup for SageMaker
Similar skills
Turborepo
Optimized build system for JavaScript/TypeScript monorepos.
Azure Pipelines Validation
Streamline your Azure DevOps pipeline changes locally.
Azure Developer CLI
Streamline your Azure project workflows with best practices.
Azure Container Registry CLI
Manage Azure Container Registry resources with ease.
Aspire
Build and orchestrate polyglot distributed applications seamlessly.
Vercel CLI
Manage and deploy Vercel projects from the command line.
