pyodbc to MSSQL connectivity from Anaconda venv #1157
-
PyODBC to SQL Server connection is getting failed with the error message 'file not found (0) (SQL Driver Connect)' on RHEL8 server. We have tried using SQL Server 13.1, 17.2, 17.4, 18.0 and 18.1 versions connectivity from python 3.7/3.9 versions using PyODBC on RHEL8 server. Please find the below error message we received when trying the connectivity in python for any version of sql server. Connection Code: Error Message: Connecting to MS SQL driver 18.0 version from python : |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 44 replies
-
You should put driver name in Driver= keyword, not path to driver file. |
Beta Was this translation helpful? Give feedback.
-
In addition to the suggestion from @v-chojas … First, verify that the file actually exists
Then, run
If one of those dependencies was missing it would appear as
|
Beta Was this translation helpful? Give feedback.
-
strace output: |
Beta Was this translation helpful? Give feedback.
-
Hi v-chojas, we tried to run the same isql command on RHEL8 server with SQL 13.1, 17.2, 18.1 versions earlier last week and shared the result with you. Can you please check back the earlier posts from me and let us know the wayforward. |
Beta Was this translation helpful? Give feedback.
-
Hi Gordthompson, can you please share an update. |
Beta Was this translation helpful? Give feedback.
-
Hi Gordthompson, Please find the below strace output of isql command. strace isql -v -k 'Driver=ODBC Driver 17 for SQL Server;Server=PL45324-DV.prodlb.travp.net,45324;Database=MI_Finance_Repository;UID=sasadm;PWD=Sasperts' -> (Executed Command) |
Beta Was this translation helpful? Give feedback.
-
And attached strace python sql.py output where pyodbc is 4.0.35 version. Connection Code in sql.py file: strace python sql.py -> (Executed Command) |
Beta Was this translation helpful? Give feedback.
-
When running in the virtual environment, Python was loading a venv-specific version of
instead of using the "system" version from
and that was causing pyodbc to fail. The fix was to adjust the venv to use the "system" version of
|
Beta Was this translation helpful? Give feedback.
-
Yes this can be done for one user. But our question is there are plenty of users who should use the same. So how can we make this solution applied for all the users. That should help a solution which should work for all. |
Beta Was this translation helpful? Give feedback.
When running in the virtual environment, Python was loading a venv-specific version of
libcrypto.so.1.1
frominstead of using the "system" version from
and that was causing pyodbc to fail. The fix was to adjust the venv to use the "system" version of
libcrypto.so.1.1
by replacing the venv-specific version with a symlink: