I am getting an error when installing pyodbc as a part of my Openshift deployment. There are numerous threads explaining the solution, including this one: pip install pyodbc failed ERROR
Error:
Building wheel for pyodbc (setup.py): started
Building wheel for pyodbc (setup.py): finished with status 'error'
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [10 lines of output]
running bdist_wheel
running build
running build_ext
building 'pyodbc' extension
In file included from src/buffer.cpp:12:0:
src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
#include <sql.h>
^
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyodbc
My question is: how do I kick off an apt install (or sudo) as a part of my deployment? I am using the OpenShift GUI.
I'm using requirements.txt to force the PIP install of all the dependencies:
pandas
numpy
dash
dash_core_components
dash_html_components
plotly.express
dash
plotly
sqlalchemy
matplotlib
pyodbc
powershift-image
YAML contents for the build:
kind: BuildConfig
apiVersion: build.openshift.io/v1
metadata:
annotations:
app.openshift.io/vcs-ref: master
app.openshift.io/vcs-uri: >-
ssh://git@sourcecode.xxdeletedxx_reports.git
openshift.io/generated-by: OpenShiftWebConsole
selfLink: >-
/apis/build.openshift.io/v1/namespaces/ci-testline-analysis-adp/buildconfigs/adp-testline-reports-git
resourceVersion: '319828205'
name: adp-testline-reports-git
uid: 6d2f69e9-8d8d-4c72-bdc0-5838be4649d9
creationTimestamp: '2022-02-08T18:30:16Z'
managedFields:
- manager: Mozilla
operation: Update
apiVersion: build.openshift.io/v1
time: '2022-02-08T20:25:20Z'
fieldsType: FieldsV1
fieldsV1:
'f:metadata':
'f:annotations':
.: {}
'f:app.openshift.io/vcs-ref': {}
'f:app.openshift.io/vcs-uri': {}
'f:openshift.io/generated-by': {}
'f:labels':
.: {}
'f:app': {}
'f:app.kubernetes.io/component': {}
'f:app.kubernetes.io/instance': {}
'f:app.kubernetes.io/name': {}
'f:app.kubernetes.io/part-of': {}
'f:app.openshift.io/runtime': {}
'f:app.openshift.io/runtime-version': {}
'f:spec':
'f:output':
'f:to':
.: {}
'f:kind': {}
'f:name': {}
'f:runPolicy': {}
'f:source':
'f:contextDir': {}
'f:git':
.: {}
'f:ref': {}
'f:uri': {}
'f:sourceSecret':
.: {}
'f:name': {}
'f:type': {}
'f:strategy':
'f:sourceStrategy':
.: {}
'f:env': {}
'f:from':
.: {}
'f:kind': {}
'f:name': {}
'f:namespace': {}
'f:type': {}
- manager: openshift-apiserver
operation: Update
apiVersion: build.openshift.io/v1
time: '2022-02-10T14:04:32Z'
fieldsType: FieldsV1
fieldsV1:
'f:spec':
'f:triggers': {}
'f:status':
'f:lastVersion': {}
namespace: ci-testline-analysis-adp
labels:
app: adp-testline-reports-git
app.kubernetes.io/component: adp-testline-reports-git
app.kubernetes.io/instance: adp-testline-reports-git
app.kubernetes.io/name: python
app.kubernetes.io/part-of: TestLine-Report
app.openshift.io/runtime: python
app.openshift.io/runtime-version: 3.8-ubi7
spec:
nodeSelector: null
output:
to:
kind: ImageStreamTag
name: 'adp-testline-reports-git:latest'
resources: {}
successfulBuildsHistoryLimit: 5
failedBuildsHistoryLimit: 5
strategy:
type: Source
sourceStrategy:
from:
kind: ImageStreamTag
namespace: openshift
name: 'python:3.8-ubi7'
env:
- name: APP_FILE
value: main.py
postCommit: {}
source:
type: Git
git:
uri: >-
ssh://git@sourcecode.xxdeletedxx_reports.git
ref: master
contextDir: /
sourceSecret:
name: openshift-key-socialcoding
triggers:
- type: Generic
generic:
secretReference:
name: adp-testline-reports-git-generic-webhook-secret
- type: ImageChange
imageChange:
lastTriggeredImageID: >-
image-registry.openshift-image-registry.svc:5000/openshift/python@sha256:c5d24000000000000000000000
- type: ConfigChange
runPolicy: Serial
status:
lastVersion: 15
To solve my issue, I had to create custom Dockerfile and deploy the application in OpenShift as a Docker image. Specifically, I used add --> from Dockerfile instead of add--> Import from Git (Python builder image) in the GUI. The Import from Git method does not allow enough flexibility to install all of the needed packages. (pyodbc , etc.)