SAM CLI executable not found - Pycharm

16.7k views Asked by At

I'm trying to configure PyCharm in order to run a Lambda Function.

First of all in AWS Toolkit I select the SAM CLI executable, and it goes well: enter image description here

Anyway, when I want to add a Lambda run configuration pycharm says: Invalid sam executable: "The system couldn't find the specific route." enter image description here

My system PATH variable: enter image description here

Someone could help me here please, I really don't know what else to do.

Many thanks! Xevi

4

There are 4 answers

1
Ravik On BEST ANSWER

This means that SAM is not installed on your system or path is not configured in pycharm. Kindly follow the instructions for installing SAM as per the AWS documentation.

0
Tuncay Elvanagac On

Actually, I encountered same problem and solved as following;

I assume that you use mac and write in terminal this;

which sam

This gives you the path where sam installed.

Then copy this and paste into sam cli executable path like below;

enter image description here

0
Doha Simon On

To help people like me: which sam should give a path to the SAM executable, like: /opt/homebrew/bin/sam

Then in Pycharm, open preferences (⌘,) Tools -> AWS, the the first input field should be 'SAM CLI Executable'.Or Put 'SAM' (uppercase) in the settings search bar.

0
Philip On

As of a 2023 edition of the toolkit, I faced a similar issue, with the additional nuance that the SAM CLI Executable field in the dialog was disabled when I tried to create a new PyCharm Serverless App project.

I solved it as follows:

  • show the AWS Toolkit tool window in an existing, standard PyCharm project. (Of course the toolkit needs to be installed already.)
  • click the gear for options, then on the ensuing menu, the wrench for Show AWS Settings. Enter the full path to the sam executable.
  • close the existing project. If you don't do this, it looks like the AWS Settings change may not take effect.
  • create a new project. I believe the SAM CLI Executable field in the dialog is still disabled! But it should not complain about not being able to find it.

It seems like OP probably made a similar setting change (perhaps via the global PyCharm settings?), so it could just be an issue of closing open projects to get that change to take.

Unless I'm completely misunderstanding the dialog, it seems sort of buggy that the path to sam isn't displayed for inspection at project creation time even after you've set it correctly.