GCP Cann't deploy with install pyodbc

可紊 提交于 2020-12-15 06:22:10

问题


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?


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/55278707/gcp-cannt-deploy-with-install-pyodbc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!