CK__
CK__

Reputation: 1311

CodeDeploy failing with error Errno::ENOEXEC with message Exec format error

I have a CodeDeploy which deploys application on Windows instances. I have a Python script which is running as part of ValidateService hooks. Below is the code I have in that script:

print("hello")

So, I have removed everything and just printing hello as part of this script. When this script is called by CodeDeploy I get below error:

error

My appspec.yml file:

  ...
  ValidateService:
    - location: scripts/verify_deployment.py
      timeout: 900

I tried getting some help on Google but got nothing. Can someone please help me here.

Thanks

Upvotes: 4

Views: 610

Answers (2)

CK__
CK__

Reputation: 1311

After so much of investigations, I found my answer. The issue is little misleading, there is nothing to do with Code format or ENOEXEC. The issue was due to Python path. While executing my script, CodeDeploy was unable to find Python (Though I had already added python.exe in Environment variable path).

Also, I found that CodeDeploy is unable to execute .py file due to Python path issue. So, I created a PowerShell script and invoking Python script from there. Like below:

C:\Users\<username>\AppData\Local\Programs\Python\Python37-32\python.exe C:\Users\<username>\Documents\verify_deployment.py

It executed Python script successfully and gave me below output:

hello

Upvotes: 0

thetillhoff
thetillhoff

Reputation: 554

As Marcin already answered in a comment, I don't think you can simply run python scripts in CodeDeploy. At least not natively.

The error you see means that Windows does not know how to execute the script you have provided. AFAIK Windows can't run python natively (like most linux distros can).

I am not very accustomed to CodeDeploy, but given the example at https://github.com/aws-samples/aws-codedeploy-samples/tree/master/applications/SampleApp_Windows, I think you have to install python first.

Upvotes: 4

Related Questions