Reputation: 290215
I am running Python 3.5 on my Linux Mint 18. I want to load the pypyodbc
module. However, no matter what I try, I always get the error:
OdbcNoLibrary: 'ODBC Library is not found. Is LD_LIBRARY_PATH set?'
In Set LD_LIBRARY_PATH before importing in python I got the suggestion to set the path to os.getcwd()
, but it did not work either and gave me the same error.
What should I install to make it work?
See the complete log of the error:
In [1]: import pypyodbc
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/home/me/env/lib/python3.5/site-packages/pypyodbc.py in <module>()
426 # First try direct loading libodbc.so
--> 427 ODBC_API = ctypes.cdll.LoadLibrary('libodbc.so')
428 except:
/usr/lib/python3.5/ctypes/__init__.py in LoadLibrary(self, name)
424 def LoadLibrary(self, name):
--> 425 return self._dlltype(name)
426
/usr/lib/python3.5/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
346 if handle is None:
--> 347 self._handle = _dlopen(self._name, mode)
348 else:
OSError: libodbc.so: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
OdbcNoLibrary Traceback (most recent call last)
<ipython-input-1-8f9e32dd2219> in <module>()
----> 1 import pypyodbc
/home/me/env/lib/python3.5/site-packages/pypyodbc.py in <module>()
437 lib_paths = [path for path in lib_paths if os.path.exists(path)]
438 if len(lib_paths) == 0 :
--> 439 raise OdbcNoLibrary('ODBC Library is not found. Is LD_LIBRARY_PATH set?')
440 else:
441 library = lib_paths[0]
OdbcNoLibrary: 'ODBC Library is not found. Is LD_LIBRARY_PATH set?'
Upvotes: 8
Views: 12967
Reputation: 43
I was running Python 3.10 in a Debian Dev Container using VS Code.
I had similar errors, but could not install python-pyodbc
.
I used the steps recommended in this answer to a similar question from JustLearning (in part because I could not install unixodbc-dev
either).
That questoin discusses pyodbc, but I am also trying to use pypyodbc like you.
Running the right steps from Install the Microsoft ODBC driver for SQL Server (Linux) for your operating system and version resolved issues like OSError: libodbc.so: cannot open shared object file: No such file or directory
and pypyodbc.OdbcNoLibrary: 'ODBC Library is not found. Is LD_LIBRARY_PATH set?'
for me.
Upvotes: 0
Reputation: 290215
Installing the python-pyodb
package solved it:
sudo apt-get install python-pyodbc
Now the import succeeds:
In [2]: import pypyodbc
In [3]:
Upvotes: 12