Skip to content

SAM package or deploy command not configured correctly #8452

Closed

Description

@ugocottin

Description:

I'm unable to use the package or deploy command.

Steps to reproduce:

# File sam/template.yml

Resource:
  ListOrgsApiLambda:
    Type: AWS::Serverless::Function
    Properties:
      AutoPublishAlias: !If
        - IsProvisioned
        - live
        - !Ref AWS::NoValue
      CodeUri: ../dist/api/organizations
      Events:
        ListOrganizations:
          Properties:
            Method: get
            Path: /organizations
            RestApiId: <rest-api-id>
          Type: Api
      Handler: list.handler
      Policies:
        - Statement:
            - Action: verifiedpermissions:isauthorizedwithtoken
              Effect: Allow
              Resource: <Policy-store-arn>
      ProvisionedConcurrencyConfig: !If
        - IsProvisioned
        - ProvisionedConcurrentExecutions: 5
        - !Ref AWS::NoValue
brew install aws-sam-cli
sam package \
    --region eu-west-1 \
    --template-file sam/template.yml \
    --s3-prefix some-stack \
    --s3-bucket templatebucket-zde1hqkcbjas \
    --output-template-file template-output.yml

Observed result:

2025-11-20 18:39:22 Command 'package' is not configured correctly. Unable to import 'samcli.commands.package'
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/aws-sam-cli/1.146.0/libexec/lib/python3.13/site-packages/samtranslator/compat.py", line 2, in <module>
    from pydantic import v1 as pydantic
ModuleNotFoundError: No module named 'pydantic'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/aws-sam-cli/1.146.0/libexec/lib/python3.13/site-packages/samcli/cli/command.py", line 265, in get_command
    mod = importlib.import_module(pkg_name)
  File "/opt/homebrew/Cellar/python@3.13/3.13.9_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1027, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/opt/homebrew/Cellar/aws-sam-cli/1.146.0/libexec/lib/python3.13/site-packages/samcli/commands/package/__init__.py", line 6, in <module>
    from .command import cli  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.146.0/libexec/lib/python3.13/site-packages/samcli/commands/package/command.py", line 11, in <module>
    from samcli.commands._utils.options import (
    ...<12 lines>...
    )
  File "/opt/homebrew/Cellar/aws-sam-cli/1.146.0/libexec/lib/python3.13/site-packages/samcli/commands/_utils/options.py", line 34, in <module>
    from samcli.commands._utils.template import TemplateNotFoundException, get_template_artifacts_format, get_template_data
  File "/opt/homebrew/Cellar/aws-sam-cli/1.146.0/libexec/lib/python3.13/site-packages/samcli/commands/_utils/template.py", line 25, in <module>
    from samcli.yamlhelper import yaml_dump, yaml_parse
  File "/opt/homebrew/Cellar/aws-sam-cli/1.146.0/libexec/lib/python3.13/site-packages/samcli/yamlhelper.py", line 25, in <module>
    from samtranslator.utils.py27hash_fix import Py27Dict, Py27UniStr
  File "/opt/homebrew/Cellar/aws-sam-cli/1.146.0/libexec/lib/python3.13/site-packages/samtranslator/utils/py27hash_fix.py", line 10, in <module>
    from samtranslator.parser.parser import Parser
  File "/opt/homebrew/Cellar/aws-sam-cli/1.146.0/libexec/lib/python3.13/site-packages/samtranslator/parser/parser.py", line 4, in <module>
    from samtranslator.model.exceptions import (
    ...<3 lines>...
    )
  File "/opt/homebrew/Cellar/aws-sam-cli/1.146.0/libexec/lib/python3.13/site-packages/samtranslator/model/__init__.py", line 9, in <module>
    from samtranslator.compat import pydantic
  File "/opt/homebrew/Cellar/aws-sam-cli/1.146.0/libexec/lib/python3.13/site-packages/samtranslator/compat.py", line 10, in <module>
    import pydantic  # type: ignore
    ^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'pydantic'
Usage: sam [OPTIONS] COMMAND [ARGS]...
Try 'sam -h' for help.

Error: No such command 'package'.

Expected result:

Works as expected :|

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: MacOs 26.1
  2. sam --version: SAM CLI, version 1.146.0
  3. AWS region: eu-west-1
  4. Installed from homebrew
{
  "version": "1.146.0",
  "system": {
    "python": "3.13.9",
    "os": "macOS-26.1-arm64-arm-64bit-Mach-O"
  },
  "additional_dependencies": {
    "container_engine": "Not available",
    "aws_cdk": "Not available",
    "terraform": "1.14.0"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_PACKAGE_PERFORMANCE",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Found this issue, maybe related: #8163

Activity

  1. added
    stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.
    on Nov 20, 2025
  2. changed the title [-]Bug: TITLE[/-] [+]SAM package or deploy command not configured correctly[/+] on Nov 20, 2025
  3. flatherskevin commented on Nov 24, 2025

    @flatherskevin

    Same here, this started on v1.146.0. Reverting to v1.145.0 allowed me to continue running these commands

  4. flatherskevin commented on Nov 24, 2025

    @flatherskevin

    aws/serverless-application-model#3831 AWS SAM CLI was updated to support Python 3.14 before the aws-sam-translator was updated to remove Pydantic 1.0

  5. ugocottin commented on Dec 1, 2025

    @ugocottin
    Author

    Fixed in version 1.149.0

  6. github-actions commented on Dec 1, 2025

    @github-actions
    Contributor

    ⚠️COMMENT VISIBILITY WARNING⚠️

    Comments on closed issues are hard for our team to see.
    If you need more assistance, please either tag a team member or open a new issue that references this one.
    If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions