aws / aws/sagemaker-python-sdk

ModuleNotFoundError: No module named `pytz` when importing `sagemaker.workflow.pipeline`

クローズ
#5,863 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
component: pipelines type: bug
主要言語
Python
スター
2.3k
フォーク
1.3k
平均マージ
1日 22時間
マージ済み PR(30日)
35

説明

- [x] PySDK V2 (2.x)
- [ ] PySDK V3 (3.x)

## Describe the bug
When importing the SageMaker Pipelines module the runtime raises:

```
ModuleNotFoundError: No module named 'pytz'
```

The SDK imports `pytz` directly from a [pipeline module](https://github.com/aws/sagemaker-python-sdk/blob/07d5847908923e9a15d2616f9fddb844e89e0fe8/src/sagemaker/workflow/pipeline.py#L24) but does not declare `pytz` in its [own install-time dependencies](https://github.com/aws/sagemaker-python-sdk/blob/v2.257.3/pyproject.toml). If dependency resolution installs `pandas>=3.x` (which no longer pulls `pytz`), `pytz` may be absent and the import fails.

## To reproduce
Create a fresh environment and run the following steps (complete and runnable):

1. Create and activate a virtualenv, then install the SDK and pandas 3.x:

```bash
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install "sagemaker==2.257.3" "pandas==3.0.0"
```

2. Create `reproduce.py` with this exact content:

```python
# reproduce.py
from sagemaker.workflow.pipeline import Pipeline

print("Imported Pipeline OK")
```

3. Run:

```bash
python reproduce.py
```

Observed result: import fails with a traceback like:

```
Traceback (most recent call last):
File "reproduce.py", line 1, in
from sagemaker.workflow.pipeline import Pipeline
File ".../site-packages/sagemaker/workflow/pipeline.py", line XX, in
import pytz
ModuleNotFoundError: No module named 'pytz'
```

## Expected behavior
Importing public SDK modules (e.g., `sagemaker.workflow.pipeline`) should not raise `ModuleNotFoundError` for direct imports used by the SDK. Installing the SDK alone should provide all runtime dependencies required by its modules.

## Screenshots or logs
See the traceback above produced by the reproduction steps.

## System information
- **SageMaker Python SDK version**: `sagemaker==2.257.3`
- **Framework name or algorithm**: N/A (issue occurs at SDK import time)
- **Framework version**: N/A
- **Python version**: `Python 3.12`
- **CPU or GPU**: CPU
- **Custom Docker image (Y/N)**: N

## Additional context
- Root cause: Historically `pandas<3` depended on `pytz`, so `pytz` was often pulled transitively. With `pandas>=3` that transitive dependency is removed, exposing the SDK's missing direct dependency on `pytz`.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start with pyproject.toml to inspect the SDK's install-time dependencies, then review the pytz import in src/sagemaker/workflow/pipeline.py. Recreate the fresh-environment steps from the issue and verify that importing Pipeline succeeds after installing the SDK alone.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
aws, pandas, python
領域
cloud, machine-learning
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
58/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。