Unable to install pyodbc on streamlit sharing

Hi there,

I have been facing difficulties in having pyodbc installed while deploying on streamlit share. May I ask if anyone has faced the same issue?

The error shown is this:

Building wheel for pyodbc (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:

For my local environment I am able to run it successfully by installing with this method:

apt install unixodbc-dev
pip install pyodbc

I have added pyodbc== 4.0.30 in my requirements.txt

Hi @sylchw, welcome to the Streamlit community!

Do you have a requires.txt file in your repo for the apt install?

I have the same problem. I have the requires.txt including pyodbc==4.0.30, but when I deploy myapp to share.streamlit.io. It always give me a message: Building wheel for pyodbc (setup.py): finished with status ‘error’. Does streamlit support the pyodbc?

Hi @Lushan1980, welcome to the Streamlit community. Yes, you should be able to install pyodbc, as shown by this example repo:

Best,
Randy

Hi @randyzwitch , Thank you very much. I already figured out the pyodbc problem. But I got a new problem: Error: (‘01000’, “[01000] [unixODBC][Driver Manager]Can’t open lib ‘ODBC Driver 17 for SQL Server’ : file not found (0) (SQLDriverConnect)”)

Traceback:

File "/usr/local/lib/python3.7/site-packages/streamlit/script_runner.py", line 332, in _run_script
    exec(code, module.__dict__)File "/app/pythonvscode/sqldb.py", line 12, in <module>
    conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)

Can you please help me to check what’s the problem?

To install system-level dependencies such as database drivers, you can add a packages.txt file to your top-level repository folder.

I don’t use SQL Server, but maybe add a packages.txt file with mssql-tools on a single line and see if that installs what you need.

Hi @randyzwitch
I add a mssql-tools in my packages.txt. Then got this message

E: Unable to locate package mssql-tools
  Stopping...

my app located in GitHub - lushan1980/PythonVScode
Can you help me check what’s wrong with it. It already bothered me 3 days.
Thank you

Unfortunately, I don’t know, I’ll try to find someone internally who specifically has experience with SQLServer

Thank you. I think the reason is sharing streamlit using ubantu OS. I checked all the package, it doesn’t have the mssql-tools package.