Having issue with new space (pyodbc error)

I am new to spaces, so forgive me if basic question. Trying to get my app.py to build, but keeps getting stuck at pyodbc import. I have pyodbc in my requirements.txt file, and build fails when it hits the import pyodbc line in app.py. Traceback below. Any ideas?

===== Application Startup at 2023-07-30 15:53:20 =====

Traceback (most recent call last):
File “/home/user/app/app.py”, line 18, in
import pyodbc
ImportError: libodbc.so.2: cannot open shared object file: No such file or directory

1 Like

Was able to advance from this erorr by having unixodbc in package.txt. However now getting driver error when trying to connect using pyodbc:

Error: (‘01000’, “[01000] [unixODBC][Driver Manager]Can’t open lib ‘SQL Server’ : file not found (0) (SQLDriverConnect)”)

Hi.
same issue here. Have you solved it yet?
Thanks in advance

could you please share a bit about what are you trying to run on Spaces? thanks

Yes, thanks for your interest
I’m using streamlit to make a data visualize app. Using pyodbc to connect with my Microsoft SQL Server database
here is my connection string, with server is <IP address,port> and this connect run perfectly local anw.

@st.cache_resource
def init_connection():
    return pyodbc.connect(
        "DRIVER={ODBC Driver 17 for SQL Server};SERVER="
        + st.secrets["server"]
        + ";DATABASE="
        + st.secrets["database"]
        + ";UID="
        + st.secrets["username"]
        + ";PWD="
        + st.secrets["password"]
    )

conn = init_connection()

@st.cache_data(ttl=600)
def run_query(query):
    data = pd.read_sql(query, conn)
    return data

there error cause at conn = init_connection()
I encoutered error exactly the post above. At first is an ImportError and after fixing by having unixodbc in package.txt, this error encounter Error: (‘01000’, “[01000] [unixODBC][Driver Manager]Can’t open lib ‘SQL Server’ : file not found (0) (SQLDriverConnect)”)

please, feel free for any ideas or info. thanks in advance