Skip to content

Elastic Beanstalk Node Environment Install Python Packages

0

I have an express server and I need to run python child processes in the server. I am trying to install the python packages but none of the options I tried have worked. I used a buildspec.yml file to download them during the build phase but that did not seem to work.

version: 0.2

phases:
  install:
    runtime-versions:
      nodejs: 20
      python: 3.9
    commands:
      - npm install
      - pip install -r requirements.txt

artifacts:
  files:
    - "**/*"
  base-directory: "./"

The files downloaded according to the build logs, but "pip list" did not produce anything when I connected to the ec2 instance and ran the terminal command.

In an ebextensions file I have:

container_commands:
  01_install_pip:
    command: |
      curl -O https://bootstrap.pypa.io/get-pip.py
      python3 get-pip.py --user
  02_verify_paths:
    command: |
      echo $PATH >> /var/log/path.log
      ls -la ~/.local/bin/ >> /var/log/path.log
      ls -la /var/app/current/ >> /var/log/path.log
  03_install_packages:
    command: |
      ~/.local/bin/pip install -r /var/app/current/requirements.txt

path.log

/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
total 16
drwxr-xr-x. 2 root root  56 Jun 15 00:12 .
drwx------. 4 root root  28 Jun 14 23:40 ..
-rwxr-xr-x. 1 root root 217 Jun 15 00:12 pip
-rwxr-xr-x. 1 root root 217 Jun 15 00:12 pip3
-rwxr-xr-x. 1 root root 217 Jun 15 00:12 pip3.9
-rwxr-xr-x. 1 root root 206 Jun 14 23:40 wheel
total 204
... REDACTED ...
-rw-rw-r--.   1 webapp webapp   1974 Jun 14 23:37 requirements.txt

but that is not working either. I get an error during the build process for this:

cfn-init.log

... Command 01_install_pip succeeded
2024-06-15 00:12:15,878 [INFO] Command 02_verify_paths succeeded
2024-06-15 00:12:21,495 [ERROR] Command 03_install_packages (~/.local/bin/pip install -r /var/app/current/requirements.txt) failed
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/cfnbootstrap/construction.py", line 579, in run_config
    CloudFormationCarpenter(config, self._auth_config, self.strict_mode).build(worklog)
  File "/usr/lib/python3.9/site-packages/cfnbootstrap/construction.py", line 277, in build
    changes['commands'] = CommandTool().apply(
  File "/usr/lib/python3.9/site-packages/cfnbootstrap/command_tool.py", line 127, in apply
    raise ToolError(u"Command %s failed" % name)
cfnbootstrap.construction_errors.ToolError: Command 03_install_packages failed
  • Is it possible that I need to edit my permissions for my instance profile or service role? or even some other permissions for Code Pipeline?

1 Answer
1

Hello.

You may be able to check more detailed ElasticBeanstalk logs by following the steps described in the documentation below.
Please check here and try troubleshooting.
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
  • Yes, I was looking at all the logs through EC2 instance connect as well. I am not seeing any useful information

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.