Reputation: 13
I'm try to use GCP (Google cloud platform) : API Service with python project. And this project need to use lib : pyodbc for connect to MSSQL
.
In localhost it fine but when I try to deploy this project to GCP it show error like this. Can someone help me with this issue?
Upvotes: 1
Views: 2537
Reputation: 161
I am getting the following error now when using the command gcloud beta app gen-config --custom: WARNING: This command is deprecated and will soon be removed.
As an alternative, create an app.yaml file yourself using the directions at https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml (App Engine Flexible Environment) or https://cloud.google.com/appengine/docs/standard/python/config/appref (App Engine Standard Environment) under the tab for your language.
To create a custom runtime, please follow the instructions at https://cloud.google.com/appengine/docs/flexible/custom-runtimes/
ERROR: (gcloud.beta.app.gen-config) This command does not support python3.
Upvotes: 0
Reputation: 2805
The machine that will run the app must have ODBC header files installed.
To do so, you will need to deploy the app in a custom run time environment, where you install this header files before installing the requirements. For more information on how to do so you can visit this answer on this Stack-overflow question.
I will also post here the process as described by Brooks Lybrand in Stack-overflow question mentioned above: (His solution is based on Connect docker python to SQL server with pyodbc)
$ gcloud beta app gen-config --custom
in the same directory with your app.Dockerfile
will be created.Edit the Dockerfile
by adding the following commands before the RUN pip install -r requirements.txt
(suggestion: add those lines after RUN virtualenv ...
and before # Set virtualenv environment variables ...
):
#Install FreeTDS and dependencies for PyODBC
RUN apt-get update
RUN apt-get install -y tdsodbc unixodbc-dev
RUN apt install unixodbc-bin -y
RUN apt-get clean -y
ADD odbcinst.ini /etc/odbcinst.ini
Create a file odbcinst.ini
if doesn't exist already
Edit the file odbcinst.ini
and add the following:
[FreeTDS]
Description=FreeTDS Driver
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
Execute $ gcloud app deploy
and it should deploy without any problems.
I have tested it myself and I was getting the same error. After this procedure the App was deployed without any issues.
Upvotes: 1