Open sryze opened 1 month ago
Adding set PYTHONNOUSERSITE=1
right before the python.exe
line in C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd
fixed it for me.
set PYTHONNOUSERSITE=1
"%~dp0/../runtime/python.exe" -m samcli %*
Hey @sryze, thanks for opening this. I don't appear to be able to reproduce the same issue.
I have both Python 3.9 and 3.12 installed for testing reasons, and also moved SAM CLI to the top of the list. I was at the bottom for me initially. Running sam init
works fine on my end, whether the entry for SAM CLI is at the top or bottom.
This is what my sam.cmd
looks like:
@rem
@echo off
setlocal
"%~dp0/../runtime/python.exe" -m samcli %*
Is this new behaviour with 1.124.0? ie. have you used older versions of SAM CLI before this that didn't break this way?
This might sound trivial, but can you try reinstalling SAM CLI?
@lucashuy Sorry, I forgot to mention that to reproduce this bug you must have the package attrs
installed, specifically version 18.1.0. In my case it's a dependency of another package (coursera-dl).
pip install --user attrs==18.1.0
Description:
When I run
sam local
or any other SAM command, they all fail:It seems that the
attr
package is supposed to be read fromC:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages
but instead it is read from the user packages folder atC:\Users\<username>\AppData\Roaming\Python\Python312\site-packages
.Steps to reproduce:
PATH
environment variableattrs
package:pip install --user attrs==18.1.0
Note:
C:\Program Files\Amazon\AWSSAMCLI\bin
comes beforeC:\Program Files\Python312
inPATH
- I double checked.Observed result:
SAM commands don't work.
Expected result:
Expected them to not use my Python installation but use the one that ships with the installer.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
:SAM CLI, version 1.124.0
Python version: 3.12.6