Joann Ren
Joann Ren

Reputation: 1

AWS SAM CLI cannot find python libraries during local invoke in VSCode after upgrade to 1.114.0 or 1.115.0 on Windows 10

Hi AWS SAM CLI experts,

I've started using SAM CLI for a couple of months with no issues, and have successfully debugged and deployed my 1st lambda function on AWS using it.

Recently, I need to develop a new lambda function for another project, so I created a new workspace and a new set of code and the code runs with no issues using the VSCode python debugger. After I change the code to debug the functions with lambda functions using SAM CLI, there was a popped up saying my SAM CLI version is invalid (something like this, sorry I didn't take a screenshot and think it is just asking for a upgrade like any other software is notifying the user for upgrade).

So I downloaded the latest version, at that time it should be 1.114.0 or a version before that I don't recall. No errors or warnings for this upgrade, sam build passed perfectly.

However, when I run "Edit SAM Debug Configuration" with Invoke Target Type "Template". Runtime: Python 3.11 etc. It cannot find the python libraries such as six, urllib3 etc by saying cannot find six.py and connection.py under my working folder where the template.yaml is saved.

I've tried

  1. uninstalled SAM CLI (1.114.0 or previous version) using add or remove program on windows and reinstall SAM CLI again and also make sure long path is enabled using elevated privilege. Same error happened.

  2. update SAM CLI using installation of another latest version 1.115.0. Same error persisted.

  3. My coworker (unfortunately he is running on mac not windows) ran exactly the same code with exactly the same settings for local invoke using 1.115.0 (he upgraded to 1.115 to help me troubleshoot) and no issues at all.

Here is my environment: aws --version aws-cli/2.15.35 Python/3.11.8 Windows/10 exe/AMD64 prompt/off

sam --version SAM CLI, version 1.115.0

environmental variables echo %PATH% ev

python libraries: i.e. py -m pip show urllib3 all installed under C:\Users\myusername\AppData\Local\Programs\Python\Python311\Lib\site-packages some exe files is installed under C:\Users\myusername\AppData\Local\Programs\Python\Python311\Scripts

Other info: I installed and uninstalled SAM CLI as a user, we don't have admin privilege. Admin privilege must be elevated as mentioned above.

Question: Why SAM CLI is looking under my working folder, but not my working folder/.aws-sam (the sub folder) to look for python libraries where the "missing" libraries are all built there? (Apparently, I don't have any clue on how SAM CLI is looking up files)

I am GUESSing something might have broken during my uninstallation/reinstallation/upgrade process. Trying to find where I could miss and what else I should try for SAM CLI to see how I can proceed and continue use the latest version SAM CLI on my windows laptop.

--- as of 2024-04-22: The latest update -----------

This is not associated with environmental variables or installation/reinstallation. I was able to make it to "import boto3". It is this boto3 library import that throw off the rest of the debugging process. I've upgraded boto3 to the latest version 1.34.88. It is still the same.

In all, it looks like I cannot initialize botocore or boto3 fully under my sam cli local invoke environment.


I've been stuck here for more than a week. Any suggestions would be helpful.

Thank you!

Upvotes: 0

Views: 134

Answers (0)

Related Questions