问题
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?
回答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
来源:https://stackoverflow.com/questions/62921554/importerror-libgl-so-1-cannot-open-shared-object-file-no-such-file-or-directo