1

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?

enter image description here

2 Answers 2

1

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)

  1. Execute $ gcloud beta app gen-config --custom in the same directory with your app.
  2. A Dockerfile will be created.
  3. 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

  4. Create a file odbcinst.ini if doesn't exist already

  5. 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

  6. 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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

links expire so post essentials here to maintain future rep.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.