2

I have a Django application which it's deployed to Amazon Elastic Beanstalk. I have to install anaconda for installing pythonocc-core package. I have created a .config file in .ebextensions folder and add the anaconda path in my wsgi.py file such as below and I have deployed it successfully.

.config file:

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'
  03_conda_activate_installation:
    command: 'source ~/.bashrc'

wsgi.py:

sys.path.append('/anaconda/lib/python3.7/site-packages')

However when I add the 04_conda_install_pythonocc command below to the continuation of this .config file, I got command failed error.

04_conda_install_pythonocc: 
command: 'conda install -c dlr-sc pythonocc-core=7.4.0'

I ssh into the instance for checking. I saw the /anaconda folder has occured. When I checked with the conda --version command, I got the -bash: conda: command not found error.

Afterwards, I thought there might be a problem with the PATH and I edited the .config file as follows and I have deployed this .config file successfully.

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'
  03_add_path:
    command: 'export PATH=$PATH:$HOME/anaconda/bin'
  04_conda_activate_installation:
    command: 'source ~/.bashrc'

But when I add the conda_install_pythonocc command again to the continuation of this edited version of .config file, it failed again and I got command failed.

In manually, all the commands work but they don't work in my .config file.

How can I fix this issue and install package with conda?

Marcin
  • 215,873
  • 14
  • 235
  • 294
Aslı Kök
  • 616
  • 8
  • 19

1 Answers1

2

I tried to replicated the issue on my sandbox account, and I successful installed conda using the following (simplified) config file on 64bit Amazon Linux 2 v3.0.3 running Python 3.7:

.ebextensions/60_anaconda.config

commands:
  00_download_conda:
    command: 'wget https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh'
  01_install_conda:
    command: 'bash Anaconda3-2020.02-Linux-x86_64.sh -b -f -p /anaconda'
  05_conda_install: 
    command: '/anaconda/bin/conda install -y -c dlr-sc pythonocc-core=7.4.0'   

Note the use off absolute path /anaconda/bin/conda and -y to not ask for manual confirmations. I only verified installation procedure, not how to use it afterwards (e.g. not how to use it in python application). Thus you will probably need to adjust it to your needs.

The EB log file showing successful installation is also provided for your reference (shortened for simplicity):

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • My build failed because of the 05_conda_install command according to my logs. – Aslı Kök Jul 13 '20 at 10:44
  • @AslıKök Which environment are you using? Same as I used for verification? As you see in my logs, there were no problems installing anaconda. Is the error msg same with my code? – Marcin Jul 13 '20 at 10:46
  • I'm using 64bit Amazon Linux 2 v3.0.3 running Python 3.7. My commands are the same with yours. I have also tried to creating a new environment and deploying but it failed again. – Aslı Kök Jul 13 '20 at 10:51
  • Error occurred during build: Command 02_conda_install_pythonocc failed – Aslı Kök Jul 13 '20 at 11:12
  • Traceback (most recent call last): File "/usr/lib64/python2.7/logging/__init__.py", line 891, in emit stream.write(fs % msg.encode("UTF-8")) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 71: ordinal not in range(128) Logged from file util.py, line 502 – Aslı Kök Jul 13 '20 at 11:12
  • @AslıKök what is `02_conda_install_pythonocc`? Its not in my answer nor in your original question? – Marcin Jul 13 '20 at 11:17
  • @AslıKök Don't know at present. I wonder why python 2.7 would be used (`"/usr/lib64/python2.7`) though. The new error seems that some encoding issues are present. Maybe you have some strange characters somewhere in your config files? – Marcin Jul 13 '20 at 11:28
  • I remove the install_anaconda config file from ebextensions and my environment is okay, now I will try to deploy with that config file again. – Aslı Kök Jul 13 '20 at 12:18
  • @AslıKök Let me know how it will go. – Marcin Jul 13 '20 at 12:35
  • 1
    Omg, deployment is successfull. Now can I import pythonocc-core directly to my .py file now? – Aslı Kök Jul 13 '20 at 12:56
  • Even though I did not change anything and did not re-deploy, the environment health in severe state again. – Aslı Kök Jul 13 '20 at 13:38
  • @AslıKök So the conda installation worked? There could be other reasons why your health is severe. Maybe you run out of resources or your application crasshed? – Marcin Jul 13 '20 at 21:14
  • How can I check it? – Aslı Kök Jul 14 '20 at 05:54
  • @AslıKök Same as before. Have to inspect logs. But I understand the conda got installed? If some, maybe new question would be better if this is new issue? – Marcin Jul 14 '20 at 05:55
  • 1
    oh I solve the issue, it was about the disk space. Thank you, your commands work! – Aslı Kök Jul 14 '20 at 11:23
  • 1
    @AslıKök No problem. Glad it worked out. And thanks for letting me know. – Marcin Jul 14 '20 at 11:24