ImportError: libGL.so.1: cannot open shared object file: No such file or directory while importing OCC

Aslı Kök

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?

Marcin

/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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

ImportError: libSM.so.6: cannot open shared object file: No such file or directory

ImportError: libtk8.6.so: cannot open shared object file: No such file or directory

Tensorflow: ImportError: libcudnn.so.7: cannot open shared object file: No such file or directory

ImportError: libcudart.so.7.0: cannot open shared object file: No such file or directory

ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory

Tensorflow: ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory

svn: error while loading shared libraries: libserf-1.so.1: cannot open shared object file: No such file or directory

Anaconda ImportError: libSM.so.6: cannot open shared object file: No such file or directory

ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory

ImportError: libgomp.so.1: cannot open shared object file: No such file or directory

ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory

ImportError: libta_lib.so.0: cannot open shared object file: No such file or directory

ImportError: libcudnn.so.7: cannot open shared object file: No such file or directory

ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

ImportError: libboost_python.so.1.65.1: cannot open shared object file: No such file or directory

ImportError: libopencv_hdf.so.3.1: cannot open shared object file: No such file or directory

ImportError libdynet.so: cannot open shared object file, No such file or directory

Error importing cv2: 'libSM.so.6: cannot open shared object file: No such file or directory'

skype: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory

error while loading shared libraries: libXinerama.so.1: cannot open shared object file: No such file or directory

ImportError: libavcodec.so.56: cannot open shared object file: No such file or directory

mplayer: error while loading shared libraries: libvdpau.so.1: cannot open shared object file: No such file or directory

apt-get error while loading shared libraries libzstd.so.1 cannot open shared object file no such file or directory

./speaks: error while loading shared libraries: libespeak-ng.so.1: cannot open shared object file: No such file or directory

ImportError: /home/dminstalluser/script/lib/prctl.so: cannot open shared object file: No such file or directory

Tensorflow shared library error; ImportError: libcuda.so.1: cannot open shared object file: No such file or directory

ImportError: libc10.so: cannot open shared object file: No such file or directory

ImportError: libopencv_hdf.so.4.5: cannot open shared object file: No such file or directory

opt/lampp/bin/httpd: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory