Closed Mohamed-0-Hassan closed 4 years ago
The pyodbc
package requires a ODBC SQL client library to be installed first. See:
You can do this be providing an executable .s2i/bin/assemble
script which includes:
#!/bin/bash
... Insert commands to install ODBC SQL client library under /opt/app-root here.
exec /opt/app-root/builder/assemble
You will need to tailor the instructions from that link to install with --prefix=/opt/app-root
. You don't want to use --libdir=/usr/lib64 --sysconfdir=/etc
options as idea is to install everything under /opt/app-root
as normal user. Don't use sudo
and when adding symlinks, do it in /opt/app-root/lib
.
See if you can work out an initial assemble
script and when hit an issue post what you are using here along with error messages and description of problem.
Alternatively, you can create a custom notebook image as a Dockerfile
build and install unixODBC-devel
as root
in that, and then revert USER
back to 1001
. You can then use that custom notebook image as you base for subsequent usage.
Below the script.
#!/bin/bash
set -x
set -eo pipefail
# Execute original assemble script.
/opt/app-root/builder/assemble
cd /tmp
# download and unzip the unixODBC driver
curl -O 'ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.4.tar.gz'
tar -xz -f unixODBC-2.3.4.tar.gz
cd unixODBC-2.3.4
# install the unixODBC driver
# note, adding "--enable-stats=no" here is not specified by Microsoft
export CPPFLAGS="-DSIZEOF_LONG_INT=8"
./configure --prefix=/opt/app-root --libdir=/opt/app-root/lib64 --sysconfdir=/opt/app-root --enable-gui=no --enable-drivers=no --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE --enable-stats=no 1> configure_std.log 2> configure_err.log
make 1> make_std.log 2> make_err.log
make install 1> makeinstall_std.log 2> makeinstall_err.log
# the Microsoft driver expects unixODBC to be here /opt/app-root/lib64 libodbc.so.1,
# so add soft links to the '.so.2' files
cd /opt/app-root/lib64
ln -s libodbccr.so.2 libodbccr.so.1
ln -s libodbcinst.so.2 libodbcinst.so.1
ln -s libodbc.so.2 libodbc.so.1
# Check the unixODBC installation
ls -l /opt/app-root/lib64/libodbc*
odbc_config --version --longodbcversion --cflags --ulen --libs --odbcinstini --odbcini
odbcinst -j
isql --version
# Install the Microsoft ODBC Driver
cd /tmp
wget https://download.microsoft.com/download/B/C/D/BCDD264C-7517-4B7D-8159-C99FC5535680/RedHat6/msodbcsql-11.0.2270.0.tar.gz
tar -xz -f msodbcsql-11.0.2270.0.tar.gz
cd msodbcsql-11.0.2270.0
./install.sh install --accept-license --force 1> install_std.log 2> install_err.log
It's failing during the installation of the driver.
Sorry for slow reply. For this you need to do what I mention earlier.
Alternatively, you can create a custom notebook image as a Dockerfile build and install unixODBC-devel as root in that, and then revert USER back to 1001. You can then use that custom notebook image as you base for subsequent usage.
So create a Dockerfile
containing:
FROM quay.io/jupyter-on-openshift/s2i-minimal-notebook-py36:latest
USER root
RUN .... this is where you add commands need to run as root
USER 1001
That install.sh
script is possibly wanting to write stuff to directories that only root
can write to. So if you can tell install.sh
to install elsewhere, installing as root
in custom docker build using a Dockerfile
may be only choice.
Once have your custom docker image, you can use that as the S2I builder image for subsequent builds.
See error below.
`Collecting pyodbc Downloading https://files.pythonhosted.org/packages/75/29/aa190749bac37ede0f11a68a75e7055254699c11572bd94213f1163dfd8f/pyodbc-4.0.27.tar.gz (242kB) |████████████████████████████████| 245kB 1.2MB/s Building wheels for collected packages: pyodbc Building wheel for pyodbc (setup.py) ... error ERROR: Command errored out with exit status 1: command: /opt/app-root/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-c2t6trcm/pyodbc/setup.py'"'"'; file='"'"'/tmp/pip-install-c2t6trcm/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-nsf6nw31 --python-tag cp36 cwd: /tmp/pip-install-c2t6trcm/pyodbc/ Complete output (14 lines): running bdist_wheel running build running build_ext building 'pyodbc' extension creating build creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/src gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python36/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYODBC_VERSION=4.0.27 -I/opt/rh/rh-python36/root/usr/include/python3.6m -c src/buffer.cpp -o build/temp.linux-x86_64-3.6/src/buffer.o -Wno-write-strings In file included from src/buffer.cpp:12:0: src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
include
compilation terminated. error: command 'gcc' failed with exit status 1
ERROR: Failed building wheel for pyodbc `
Also tried to execute 'yum install unixODBC-devel' this give me the following error. Loaded plugin: fastestmirror, ovl, ovl: Error while doing RPMdb copy-up [Errno 13] Permission denied: '/var/lib/rpm/.rpm.lock' You need to be root to perform this command.