I have a newly installed anaconda environment on redhat 8. I installed microsoft ODBC driver, kerberos,etc. all without problem. Then I installed Anaconda.
The pyodbc seemed automatically installed on “base”. I then created a new environment:
“conda create -n tstdev python=3.9”
then install pyodbc:
“conda activate tstdev; conda install pyodbc”
Strange thing happens. I can use pyodbc in “base” env, but not the other env.
(base) [admsagz@srvaz01c01-jobd ~]$ conda activate base
(base) [admsagz@srvaz01c01-jobd ~]$ python test-pyodbc.py
[(154, )] **=> pyodbc works in base **
(base) [admsagz@srvaz01c01-jobd ~]$ conda activate tstdev
(tstdev) [admsagz@srvaz01c01-jobd ~]$ python test-pyodbc.py
Traceback (most recent call last):
File “/home/[email protected]/test-pyodbc.py”, line 13, in
conn = pyodbc.connect(‘Driver={ODBC Driver 17 for SQL Server};Server=abc.com;Database=DAI_NLP_DEV;Trusted_Connection=yes;Mars_Connection=yes’)
pyodbc.Error: (‘01000’, “[01000] [unixODBC][Driver Manager]Can’t open lib ‘/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.8.so.1.2’ : file not found (0) (SQLDriverConnect)”)
The “missing” file exists and accessible, otherwise the pyodbc on base would not have worked.
Would anyone provide some clue? Thanks in advance.
I would assume conda activate de-configured an environment variable somewhere. If you use the env command from within and without the activated environment, would you be able to determine which one it is?
Another finding, the pyodbc worked when I created a new environment which cloned the “base”. It sounded like there were some pyodbc dependencies issue given the “base” had lots more packages installed than python3.9 + pyodbc. However, cloning is not a sufficient option for us because it would limit the python version to the base version.
I’d like to report back the findings. The missing dependency was krb5 in our case. One would expect python to use operating system’s krb5 if it’s not included in conda but it was not the case.