Loprz / pypyodbc

Automatically exported from code.google.com/p/pypyodbc
0 stars 0 forks source link

Cannot find libodbc.so on linux #17

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Install libodbc.so and the drivers in /usr/local/lib
2. Try to use pypyodbc
3. See the error

What is the expected output? What do you see instead?
Error: it cannot load the library

What version of the product are you using? On what operating system?
pypyodbc 1.1.1, linux

Please provide any additional information below.

I looked at the portion of the code that deals with loading the library.
It uses ctypes.util.find_library function. According to the manual 
http://docs.python.org/3/library/ctypes.html (and I verified it), on Linux it 
returns only the file name of the library, but not the full path. So it is 
pretty much useless, the library will not load this way.
The workaround is: set LD_LIBRARY_PATH properly before running the program
. This will also help to load the drivers.

Here is my suggestion: simplify that piece of code, do only the LoadLibrary 
call. If it fails, just print error message and suggest to the user to set 
LD_LIBRARY_PATH.

Original issue reported on code.google.com by lilyev...@gmail.com on 5 Jul 2013 at 7:30

GoogleCodeExporter commented 8 years ago
Thanks, Error messages have been updated per the suggestion:

   raise OdbcNoLibrary('ODBC Library is not found. Is LD_LIBRARY_PATH set?')

Updated  in GitHub:
https://github.com/jiangwen365/pypyodbc/blob/master/pypyodbc.py

Original comment by jiangwen...@gmail.com on 6 Jul 2013 at 2:45