-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing location of libodbc.2.dylib on macOS #681
Comments
I would recommend using the latest unixODBC rather then iodbc, there is more discussion here: #444 |
To the best of my knowledge, I am using unixODBC. |
Ah good find! Not sure if I can work around it then. |
If the pre-compiled wheel file won't work for you then you could try installing from source ...
... but you'd need to have a C++ compiler and the unixODBC development (header) files on your machine for that to work. |
I looked into it a bit more and it looks like if you ldd that .so file you can see When I have time I want to investigate it further, but the .so file seems to be created if you run |
Want to thank both @gordthompson and @v-makouz for their response, it's been super appreciated. I didn't bring it up initially, but I have tried to build from source and that also seems to run into issues. ~
❯ pip install --no-binary pyodbc pyodbc
...
In file included from src/buffer.cpp:12:
src/pyodbc.h:56:10: fatal error: 'sql.h' file not found
#include <sql.h>
^~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1
----------------------------------------
... Which mirrors some of the issues shown in #101 Like before, I know ~
❯ cd ~/homebrew
~/homebrew stable
❯ find . -name 'sql.h'
./include/sql.h
./Cellar/unixodbc/2.3.7/include/sql.h So again when PyODBC looks for P.S. I changed the directory from |
Want to update the issue with my solution. The clang issues can be solved by adding unixODBC's path to these environmental variables: export LDFLAGS="-L/Users/pcosta/homebrew/opt/unixodbc/lib $LDFLAGS"
export CPPFLAGS="-I/Users/pcosta/homebrew/opt/unixodbc/include $CPPFLAGS"
export PKG_CONFIG_PATH="/Users/pcosta/homebrew/opt/unixodbc/lib/pkgconfig $PKG_CONFIG_PATH" This makes it possible to run It would be nice if users would be able to specify locations of drivers to avoid the build process, but I realize this is a specific edge case. |
I don't think this is a specific edge case. It holds for all mac users who use homebrew or macports (like me). |
@Thomasillo Note that this seems to only apply to the case where you have an atypical homebrew installation. In my case, I had installed homebrew into If you think this is not the case, I'd be happy to reopen if you're having issues. |
It applies also to the typical mac ports install directory. |
Gotcha @Thomasillo. Glad my instructions helped you out! I have never used MacPorts—so thanks for the clarification. That sounds fair. I'll reopen the issue. The official ask then is to allow for more flexibility for the location of the necessary unixODBC files when installing pyodbc as a wheel. |
Yes, I spent an afternoon spinning my wheels on this one. If you install your unixODBC and FreeTDS via MacPorts, you are just. out of luck--pyodbc will not see them. It would be nice to have an package installer-agnostic way of making all this work. |
Due to how the Mac dynamic linking system works, there will be hardcoded absolute paths in the binaries. It's not really possible to work around that without adding own dynamic searching and loading logic, which can be quite complex. |
@v-chojas |
Facing same issue, the file libodbc.2.dylib is not available after unixodbc installation, Why M3 Silicon chip is behaving weird? |
I solved this by adding:
To be up to date with the latest version of unixodbc https://packages.debian.org/sid/libodbcinst2 |
cc: @Himanshup21234 |
Environment
To diagnose, we usually need to know the following, including version numbers. On Windows, be
sure to specify 32-bit Python or 64-bit:
Issue
When importing pyodbc
I know why this is happening, as I don't have
libodbc.2.dylib
in the expected location. The reason is I do not have permission to write to/usr/local/
, so I have Homebrew installing into~/.brew
. This mostly works fine. I am even able to get bothtsql
andisql
working as expected by following the steps outlined here: https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-Mac-OSX.So I do have
libodbc.2.dylib
, it's just that it lives in/Users/pcosta/.brew/opt/unixodbc/lib
, not/usr/local/opt/unixodbc/lib
.The main questions is can I get pyodbc to look for
libodbc.2.dylib
(and other associated files) in another directory?I have all the files needed and have configured them correctly, I just need to repoint pyodbc somehow.
Thanks!
The text was updated successfully, but these errors were encountered: