1

Built a flask app that works when I run it locally (Windows 10). Deployment through local git is successful, but when I try to visit the url, all I see if Application Error. So when I check the log stream, it shows that the app breaks down when it tries to import pyodbc with the error "ImportError libodbc.so.2: cannot open shared object file."

So I SSH'ed into the container, activated the virtual environment, called open python and called import pyodbc and it worked. Now I'm confused as to why it would fail when I try to visit the URL, vs when I SSH and import pyodbc myself it would work. I'm not sure if I've provided enough detail so let me know if I should add anything else.

What is going on? How do I fix my container so that it can import pyodbc?

user152836
  • 25
  • 1
  • 3

1 Answers1

0

@user152836 - Can you please let us know the following information to debug further:

  1. Version of python that you are using in your web app? Native or extension?
  2. OS of your web app?

If you installed a python extension, the problem could be that azure web app uses default python which does not have the pyodbc driver. In order to use the python extension you can follow this thread - install odbc driver to azure app service

You also need to export the relevant LD LIBRARY path and add it in your bash profile file as in this example: Python executable not finding libpython shared library

If the above two suggestions don't work, you can also check this link: pyodbc - error while running application within a container

AmanGarg-MSFT
  • 1,123
  • 6
  • 10
  • I've decided to just build a custom docker container, install the necessary drivers in the container and deploy the container. – user152836 Nov 30 '18 at 17:42