By using AWS re:Post, you agree to the Terms of Use

AWS Elastic Beanstalk Python Application ebextenstions pip install command failed

0

Hi I am deploy an EB Python Web Application to a private VPC without internet access. I will install python dependency packages offline. I have all the packages ready together with application file.

application.py
packages/*.whl
packages/requirements.txt (CONTENT will be those whl packages name)
.ebextensions/python_packages.config
...
OTHER_VENV_RELATED_FOLDERS

The ebextensions/python_packages.config content:

commands:
  use_python_venv:
    command: source /opt/elasticbeanstalk/deployment/env
  install_python_requirements: 
    command: pip install --no-index --find-links /var/app/current/packages -r /var/app/current/packages/requirements.txt

The application tested working on my local computer and I zipped application.py, ebextensions and packages folder into one zip file and upload and deploy into one single instance with EIP.

it gets the below failed message in /var/log/cfn-init-cmd.log on the AMI EC2 instance. (python3.8 runtime)

022-03-25 06:59:11,289 P3318 [INFO] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2022-03-25 06:59:11,289 P3318 [INFO] Config prebuild_0_test_xl
2022-03-25 06:59:11,289 P3318 [INFO] ============================================================
2022-03-25 06:59:11,289 P3318 [INFO] Command install_python_requirements
2022-03-25 06:59:12,675 P3318 [INFO] -----------------------Command Output-----------------------
2022-03-25 06:59:12,675 P3318 [INFO] 	ERROR: Could not open requirements file: [Errno 2] No such file or directory: '/var/app/current/packages/requirements.txt'
2022-03-25 06:59:12,675 P3318 [INFO] ------------------------------------------------------------
2022-03-25 06:59:12,675 P3318 [ERROR] Exited with error code 1

I checked the path of the requirements.txt file and it is not there and here is the directory and files under that /var/app directory:

staging/Pipfile
venv

It means the /var/app/current directory not get created so my command failed. Where is my package file during the staging process?

How can I install offline python dependency packages on ElasticBeanstalk EC2 instance without internet access? Edit Pipfile instead? Thank you

asked 6 months ago58 views
1 Answer
0

resolved the issue by putting an empty requirements.txt in the working folder and move all whl binary pkgs and requirements.txt file with those pkg info to the packages subfolder. Then used container_commands to do the trick.

container_commands:
  01_install_python_packages:
    command: "$PYTHONPATH/pip install --no-index --find-links ./packages -r ./packages/requirements.txt"
answered 6 months ago

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.

Guidelines for Answering Questions