1

I have a Django application which it's deployed to Amazon Elastic Beanstalk(Python 3.7 running on 64bit Amazon Linux 2/3.0.3). I have installed anaconda and pythonocc-core package by creating a 10_anaconda.config file in .ebextensions folder.

10_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'
  02_conda_install_pythonocc: 
    command: '/anaconda/bin/conda install -y -c dlr-sc pythonocc-core=7.4.0'

Then I have created a folder in one of my apps and created a __init__.py and cadLoader.py file into that folder. I have added the anaconda path to __init__.py which it's in the cad folder;

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

And I have added the import lines to cadLoader.py for trying;

import os
from OCC.Extend.DataExchange import read_stl_file
from OCC.Display.SimpleGui import init_display
from OCC.Core.GProp import GProp_GProps
from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import read_iges_file
from OCC.Core.Bnd import Bnd_Box
from OCC.Core.BRepMesh import BRepMesh_IncrementalMesh
from OCC.Core.BRepBndLib import brepbndlib_Add
from OCC.Core.BRepGProp import brepgprop_VolumeProperties

When I deployed it to Elastic Beanstalk, I got the error lines below.

from data.modellib.cad.cadLoader import CADLoader
File "/var/app/current/data/modellib/cad/cadLoader.py", line 2, in <module>
from OCC.Extend.DataExchange import read_stl_file
File "/anaconda/lib/python3.7/site-packages/OCC/Extend/DataExchange.py", line 32, in <module>
from OCC.Core.XCAFDoc import (XCAFDoc_DocumentTool_ShapeTool,
File "/anaconda/lib/python3.7/site-packages/OCC/Core/XCAFDoc.py", line 18, in <module>
from . import _XCAFDoc
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

According to this issue, I have added a .config file for installing libGL such as below:

packages:
  yum:
    mesa-libGL : []
    mesa-libGL-devel : []

And in order to solve the version ZLIB_1.2.9 not found error, I added a config file like the one below.

commands:
    00_download_zlib:
        command: 'wget https://github.com/madler/zlib/archive/v1.2.9.tar.gz'
    01_open_zlib:
        command: 'tar xzvf v1.2.9.tar.gz'
    02_into_zlib:
        command: 'cd zlib-1.2.9'
    03_make_zlib:
        command: 'make'
    04_make_install_zlib:
        command: 'make install'
    05_libz_so:
        command: 'ln -fs /usr/local/lib/libz.so.1.2.9 /lib64/libz.so'
    06_libz_so_1:
        command: 'ln -fs /usr/local/lib/libz.so.1.2.9 /lib64/libz.so.1'

But my deployment is failed because of the make command. Here is my error message:

Unhandled exception during build: Command 03_make_zlib failed
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_make_zlib failed

How can I fix this issue and use the OCC package in my application?

Aslı Kök
  • 616
  • 8
  • 19
  • 1
    You have to satisfy the dependency on libGL with your system's package manager. For ubuntu you would e.g. need to do `sudo apt-get install libgl1`. Probably you can find a reverse package search for your distribution [(e.g. this for ubuntu)](https://packages.ubuntu.com/search?suite=eoan&section=all&arch=any&keywords=libGL.so.1&searchon=contents) – cel Jul 15 '20 at 18:41
  • I installed the `mesa-libGL` and `mesa-libGL-devel`. the deployment was successfull but when I try to access the website, I'm getting `/lib64/libz.so.1: version ZLIB_1.2.9 not found (required by /anaconda/lib/python3.7/site-packages/OCC/Core/../../../../././././libpng16.so.16)` error – Aslı Kök Jul 15 '20 at 19:36

1 Answers1

1

/lib64/libz.so.1: version ZLIB_1.2.9 not found

Amazon Linux 2 provides version 1.2.7:

Name        : zlib
Arch        : i686
Version     : 1.2.7
Release     : 18.amzn2
Size        : 91 k
Repo        : amzn2-core/2/x86_64
Summary     : The compression and decompression library
URL         : http://www.zlib.net/
License     : zlib and Boost
Description : Zlib is a general-purpose, patent-free, lossless data compression
            : library which is used by many different programs.

You can try manually upgrading the zlib to 1.2.9, for example performing the following steps as root (if they work, you can automated this through .ebextentions):


wget https://github.com/madler/zlib/archive/v1.2.9.tar.gz
tar xzvf v1.2.9.tar.gz
cd zlib-1.2.9
./configure
make
make install

ln -fs /usr/local/lib/libz.so.1.2.9 /lib64/libz.so
ln -fs /usr/local/lib/libz.so.1.2.9 /lib64/libz.so.1

This have to be carefully tested, as manual upgrades can break things. Some other options for upgrades are here.

New config file

commands:
    00_download_zlib:
        command: |
            wget https://github.com/madler/zlib/archive/v1.2.9.tar.gz
            tar xzvf v1.2.9.tar.gz
            cd zlib-1.2.9
            ./configure
            make
            make install
            ln -fs /usr/local/lib/libz.so.1.2.9 /lib64/libz.so
            ln -fs /usr/local/lib/libz.so.1.2.9 /lib64/libz.so.1
Marcin
  • 215,873
  • 14
  • 235
  • 294
  • I'm trying manually now. When I run the `make install` command, I'm getting `mkdir: cannot create directory ‘/usr/local/lib/pkgconfig’: Permission denied make: [install-libs] Error 1 (ignored) cp libz.a /usr/local/lib cp: cannot create regular file ‘/usr/local/lib/libz.a’: Permission denied make: *** [install-libs] Error 1` error – Aslı Kök Jul 16 '20 at 06:32
  • @AslıKök You have to be root. `sudo su` – Marcin Jul 16 '20 at 06:33
  • now all the commands work. I will create my `.config` file as you said. Do I need the `sudo su` in my `.config` file? – Aslı Kök Jul 16 '20 at 06:35
  • @AslıKök You mean your python script works? Yes, you can make it in config file. config files run as root anyway. – Marcin Jul 16 '20 at 06:37
  • I've created my config file and deployed the application but I got an error in `make` command. – Aslı Kök Jul 16 '20 at 06:43
  • `Error encountered during build of prebuild_1_sfm_app: Command 03_make_zlib failed Traceback (most recent call last): 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)` – Aslı Kök Jul 16 '20 at 06:46
  • @AslıKök Maybe better if you update your question. I don't know what is your config file. – Marcin Jul 16 '20 at 06:47
  • @AslıKök Try to add `./configure` as in the updated answer. – Marcin Jul 16 '20 at 06:57
  • oh yes, you're right. I have added while I was trying manually but I have forgotten to add to the config file. I'm trying again. – Aslı Kök Jul 16 '20 at 07:00
  • @AslıKök I added `configure` now as well. I also forgot about it originally :-( Not sure if this is the reason why the config file failed. – Marcin Jul 16 '20 at 07:04
  • it failed on `./configure` :( – Aslı Kök Jul 16 '20 at 07:05
  • @AslıKök Have to login to the instance and re-check the commands. – Marcin Jul 16 '20 at 07:06
  • I've tryed to run these commands manually again and all of them work. – Aslı Kök Jul 16 '20 at 07:07
  • @AslıKök I will have to try to replicate the config file on my eb instance and check. I don't know for now. – Marcin Jul 16 '20 at 07:08
  • Okay thank you for your time. If you find anything please share with me :) – Aslı Kök Jul 16 '20 at 07:09
  • @AslıKök I modified the answer. Had the same issue. New form of the config file works for me. And the reason it was failing was that the `commends` do not "remember" executing `cd zlib-1.2.9`. Co `make` or `configure` were executing in wrong folder. – Marcin Jul 16 '20 at 07:41
  • Sorry, i couldn't understand what's the difference between your modified answer and my config file – Aslı Kök Jul 16 '20 at 08:00
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/217945/discussion-between-asli-kok-and-marcin). – Aslı Kök Jul 16 '20 at 08:04