0

I have a Django application which it's deployed to Elastic Beanstalk, Amazon Linux 2 AMI and I'm very new with AWS. I have to use pythonocc-core package in my application and I cannot install it via pip. If I SSH into an instance and install it manually, it won't be a great way because of autoscaling of EB environment. I added the .config file below for installing anaconda and my deployment was successful.

commands:
  00_download_conda:
    command: 'wget https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh'
    test: test ! -d /anaconda
  01_install_conda:
    command: 'bash Anaconda3-2020.02-Linux-x86_64.sh -b -f -p /anaconda'
    test: test ! -d /anaconda
  02_create_home:
    command: 'mkdir -p /home/wsgi'

Deployment failed when I added the following command lines to the continuation of this .config file.

commands:
  03_conda_create: 
    command: conda create --name=whatever-name python=3.7
  04_conda_activate: 
    command: source activate whatever-name
  05_conda_install: 
    command: conda install -c dlr-sc pythonocc-core=7.4.0

But I've got an error such as below.

Traceback (most recent call last):
  File "/opt/aws/bin/cfn-init", line 171, in <module>
    worklog.build(metadata, configSets)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 129, in build
    Contractor(metadata).build(configSets, self)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 530, in build
    self.run_config(config, worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
    changes['commands'] = CommandTool().apply(self._config.commands)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
    raise ToolError(u"Command %s failed" % name)
ToolError: Command 03_conda_create failed

How can I fix this issue?

Aslı Kök
  • 616
  • 8
  • 19

1 Answers1

0

A good way would be to use Commands in your .ebextensions folder.

For example, you could have a file .ebextensions/10_install_pythonocc.config:

commands:
  10_conda_create: 
    command: conda create --name=whatever-name python=3.7
  20_conda_activate: 
    command: source activate whatever-name
  30_conda_install: 
    command: conda install -c dlr-sc pythonocc-core=7.4.0

Regarding anaconda itself, here are instructions that can be tried.

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • @AslıKök Hi, you can add analogical first step `05_anaconda:` and command for the anaconda. You haven't included the command in your question. So how do you do it manually when you login to the instance? – Marcin Jul 06 '20 at 09:55
  • I tried the way in this link https://stackoverflow.com/questions/24921415/installing-anaconda-on-amazon-elastic-beanstalk and it works but when I add the commands that you mentioned, I got ```command failed``` error. – Aslı Kök Jul 06 '20 at 11:15
  • @AslıKök Can you be more specific? How did you add them? These are the commends you provided? Do you get any error messages? – Marcin Jul 06 '20 at 11:16
  • I added them in a .config file and I have deployed successfully. After that I added the commands for installing pythonocc-core, the deployment is failed and my error message was ```Command failed in all instances``` – Aslı Kök Jul 06 '20 at 11:19
  • @AslıKök Can you update the question with current state of your `.ebextensions` and the content of the config files. – Marcin Jul 06 '20 at 11:22
  • @AslıKök You have to get the log files and inspect them. There should be more useful error message there. – Marcin Jul 06 '20 at 11:41
  • @AslıKök I tried to replicate but I've noticed that the anaconde requires lots of disk space. Are you sure you are not running out of disk space? – Marcin Jul 06 '20 at 13:16
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/217321/discussion-between-asli-kok-and-marcin). – Aslı Kök Jul 06 '20 at 15:57