[Driver Manager]Can't open lib file not found (0) Apple M1
MrRobot245 opened this issue · 49 comments
Installed ODBC and msodbcsql mssql-tools all through brew on native ARM64 M1 Mac, install proceeds fine but it can't seem to find libmsodbcsql.17.dylib
I've tried symbolic linking to the /etc/ home-brew path like in the documents, and also changing the path inside the ini file to exactly the libmsodbcsql.17.dylib file.
Chmod 777 the file and I still get this error:
[unixODBC][Driver Manager]Can't open lib '/opt/homebrew/lib/libmsodbcsql.17.dylib' : file not found (0) (SQLDriverConnect)"
/opt/homebrew/lib/ being the new Brew folder for M1 Macs
Edit:
/opt/homebrew/lib/libmsodbcsql.17.dylib -> ../Cellar/msodbcsql17/17.6.1.1/lib/libmsodbcsql.17.dylib
No support for ARM64 at the moment.
That's what I figured, but it didn't get me an arch error so I thought it was something I could fix.
Would this work under Rosetta2?
If your application and its dependencies are also consistently x86_64, I don't see why not.
Running into the same issue report by @MrRobot245 and have been unable to resolve. Happy to provide more information if needed, understand support is only for x86_64 but would be good to know if there is a workaround to make use of Rosetta2
Mine did work with Rosetta2,
Kill the native brew version, duplicate your terminal all and check the Rosetta2 box and reinstall brew/MSSQL
Until there's a arm64 version that's what I'll be doing.
Thanks @MrRobot245, those instructions worked for me, appreciate the help.
Is there any timeline on arm? I do not want to remove and reinstall my full software stack just because of this ODBC driver
FreeTDS works so far, but I am deploying to a Unix environment and would like to develop more closely to that environment
Is there any hope for a M1-compatible update, or is this not happening?
@nico525 @fonnesbeck M1 ARM support is being worked on. Barring any blocking issues, it is planned be in our next regular release at the end of July.
Thanks for the update.
@David-Engel is there any news about the new version of this driver for M1 ARM? July is coming soon...
@wizardion - I'm filling in for David at the moment and can say that the end-of-July release is on track to include M1 ARM support.
Hi @vwarchu - any update on the release for M1 ARM support?
@victoriawallace End of July == the last day of the month. If you want to get notifications of driver releases, you can subscribe to our blog at https://techcommunity.microsoft.com/t5/sql-server/bg-p/SQLServer/label-name/SQLServerDrivers
Hi @David-Engel
I've tried reinstalling the ODBC Driver 17 for macOS following the release on Saturday -
$ odbcinst -j
unixODBC 2.3.9
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /Users/vikki.wallace/odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
$ cat /etc/odbcinst.ini
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/usr/local/lib/libmsodbcsql.13.dylib
UsageCount=2
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/homebrew/lib/libmsodbcsql.17.dylib
UsageCount=5
$ ls -la /opt/homebrew/lib/libmsodbcsql.17.dylib
lrwxr-xr-x 1 vikki.wallace admin 56 31 Jul 16:54 /opt/homebrew/lib/libmsodbcsql.17.dylib -> ../Cellar/msodbcsql17/17.8.1.1/lib/libmsodbcsql.17.dylib
but I still can't connect -
>>> pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE=qai;UID='+username+';PWD='+password)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/opt/homebrew/lib/libmsodbcsql.17.dylib' : file not found (0) (SQLDriverConnect)")
>>> pyodbc.connect('DRIVER={/opt/homebrew/Cellar/msodbcsql17/17.8.1.1/lib/libmsodbcsql.17.dylib};SERVER='+server+';DATABASE=qai;UID='+username+';PWD='+password)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/opt/homebrew/Cellar/msodbcsql17/17.8.1.1/lib/libmsodbcsql.17.dylib' : file not found (0) (SQLDriverConnect)")
Can you please advise?
Thanks
Everything works! Thank you!
Try to use connection string like this
driver = 'ODBC Driver 17 for SQL Server'
SQLALCHEMY_CONNECTION_STRING = 'mssql+pyodbc://{2}:{3}@{0}/{1}?driver={4}&Port=1433'.format(
DB_SERVER, DB_NAME, DB_USER, DB_PASSWORD, driver)
and after put it in sqlalchemy.engine.create_engine()
@RomkaSk Thanks for the heads up about the release notes. I just edited those and the mac install page to note the added M1 support. It should be reflected after tomorrow morning. Glad it's working for you!
Still doesn't work for me on Air M1. With driver = 'ODBC Driver 17 for SQL Server'
, I'm still getting
Can't open lib '/usr/local/lib/libmsodbcsql.17.dylib' : file not found
any help?
/usr/local/lib
is where the x86 one should be. Did you install from a native ARM64 brew or one running under Rosetta2 emulation?
I installed it from the native ARM64 brew. When installed from brew under Rosetta2, the path is ../Cellar/msodbcsql17/17.8.1.1lib/libmsodbcsql.17.dylib
, and it works fine in that case. But the point is that I want to remove brew under Rosetta2 and keep just the native one
Please try to remove it from the Rosetta2 brew, then install from the native one.
Also make sure you are using native isql
when testing connection, i.e. when running which isql
result should be in /opt/homebrew/
instead of /usr/local
.
@RomkaSk I'm using the driver as you said 'driver = 'ODBC Driver 17 for SQL Server' ' but I'm still getting the error below
Can't open lib '/opt/homebrew/lib/libmsodbcsql.17.dylib' : file not found
Any help ?
Are you using native arm64 isql?
@v-chojas I think yes, how can I check this ?
PS : When I type isql --version I get : unixODBC 2.3.9
I am having similar problems with the arm64 release.
I was getiting:
Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/opt/homebrew/lib/libmsodbcsql.17.dylib' : file not found (0) (SQLDriverConnect)")
Then I noticed that /opt/homebrew/lib/libmsodbcsql.17.dylib is linked to /opt/homebrew/Cellar/msodbcsql17/17.8.1.1/lib/libmsodbcsql.17.dylib
so I updated odbcinst.ini
[ODBC Driver 17 for SQL Server] Description=Microsoft ODBC Driver 17 for SQL Server #Driver=/opt/homebrew/lib/libmsodbcsql.17.dylib Driver=/opt/homebrew/Cellar/msodbcsql17/17.8.1.1/lib/libmsodbcsql.17.dylib UsageCount=1
But that didn't help.
Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/opt/homebrew/Cellar/msodbcsql17/17.8.1.1/lib/libmsodbcsql.17.dylib' : file not found (0) (SQLDriverConnect)")
Has anyone actually gotten this to work on Apple arm64 silicon? I tried on 2 separate machines with the same result.
I've installed homebrew from scratch and then ODBC driver and mssql-tools
- /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
- brew update
- HOMEBREW_NO_ENV_FILTERING=1 ACCEPT_EULA=Y brew install msodbcsql17 mssql-tools
I have no problem running a simple SELECT @@version
using isql
something in our environments are different.
Are those the defaults for you? My defaults are in /etc/ while yous appear to be in /opt/homebrew/etc/
unixODBC 2.3.9
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /Users/baywatch/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
I do have /opt/homebrew/lib/libmsodbcsql.17.dylib but I get errors that
('01000', "[01000] [unixODBC][Driver Manager]Can't open lib /opt/homebrew/lib/libmsodbcsql.17.dylib : file not found (0) (SQLDriverConnect)")
fresh install, and just got the same behavior.
Did you install unixodbc using homebrew, @JayBaywatch ?
My env was basically clean... it was only used for testing installation. Please make sure your homebrew was installed in the native mode not Rosetta2
the first atempt, I installed unixodbc and freetds from homebrew. subsequent attempts, I let homebrew pull the dependencies from the msodbc recipe.
/usr/bin/arch reports arm64
Please remove and try again the installation.
hm, that works for isql now. but still no dice from python. Although I am no longer getting a complaint about/opt/homebrew/lib/libmsodbcsql.17.dylib not being found.
This is progress, thank you.
Great, @JayBaywatch !
For the others, to quickly check if isql
is native, run file /opt/homebrew/bin/isql
The expected output is /opt/homebrew/bin/isql: Mach-O 64-bit executable arm64
even using a minimalist sample from python I get errors.
server = 'DB-DEV01'
username = 'user'
password = 'p@assword'
pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE=Master;UID='+username+';PWD='+password)
Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/opt/homebrew/lib/libmsodbcsql.17.dylib' : file not found (0) (SQLDriverConnect)")
isql still works though. weird.
Does otool -L '/opt/homebrew/lib/libmsodbcsql.17.dylib'
show any "file not found" errors?
You can also use dtruss
to determine which file exactly it is not found.
Thanks, I had tried otool and everything seemed fine.
otool -L /opt/homebrew/lib/libmsodbcsql.17.dylib
/opt/homebrew/lib/libmsodbcsql.17.dylib:
/opt/homebrew/opt/msodbcsql17/lib/libmsodbcsql.17.dylib (compatibility version 0.0.1, current version 8.1.1)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1770.255.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
/opt/homebrew/lib/libodbcinst.2.dylib (compatibility version 3.0.0, current version 3.0.0)
/System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos (compatibility version 5.0.0, current version 6.0.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)
sqlcmd and isql both work, so I guess I have to assume that this is a pyodbc issue at this point.
edit: unsure if those compatibility versions are normal or not.
You are using ARM64 Python and pyODBC? https://github.com/mkleehammer/pyodbc/issues <- you can ask there
hey, thanks for that. There is a suggestion over there to build from source. I can try that.
hey, thanks for that. There is a suggestion over there to build from source. I can try that.
For me, it didn't work when running Python via Rosseta emulation although I had drivers properly installed. Switching to python 3.9.5 which runs nativly on ARM solved the issue.
So, you need to run both python and msssql drivers nativly in order to make it work.
If everything is consistently running in emulation (from application to driver) that should work too, and would be your only choice if you have an x86 app that you need to use with the ODBC driver.
However, everything running natively in ARM mode should also work. The key point to remember is to not mix the two architectures' binaries together.
just wanted to circle back to say thanks and that worked.
In case it's ever helpful to anyone else the steps are below.
- Uninstall msodbc 17: brew remove msodbcsql17 mssql-tools
- Remove any symlinks to odbcinst.ini and odbc.ini
- Remove pyodbc, if applicable (pip uninstall pyodbc)
- Install a separate instance of homebrew as outlined below:
https://medium.com/swlh/run-x86-terminal-apps-like-homebrew-on-your-new-m1-mac-73bdc9b0f343 - in a terminal running Rosetta (as described in step 4) do the following steps below.
- install the msodbc 17 driver per the directions below:
https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver15 - customize odbc.ini (if applicable)
- ensure odbcinst.ini path (odbcinst -j)
Thanks a lot @JayBaywatch!
I have written up some instructions to get pyodbc to work on the M1 as well:
One can only use pyodbc
when using Rosetta (x86 emulation).
Follow the steps below.
Uninstall M1 versions of brew packages (if installed at all):
brew uninstall unixodbc msodbcsql17 mssql-tools freetds
Install x86 Homebrew alongside the ARM M1 homebrew:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Then use x86 homebrew like arch -x86_64 /usr/local/bin/brew install
or use the following alias (add to ~/.bash_profile
)
# Relies on having installed x86 brew like:
# arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
alias x86brew="arch -x86_64 /usr/local/bin/brew"
alias brew="/opt/homebrew/bin/brew" # M1 version, to avoid from using x86 version accidentally
Install the ODBC packages.
x86brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
x86brew update
HOMEBREW_ACCEPT_EULA=Y x86brew install msodbcsql17 mssql-tools
Create an x86 conda
env with:
ENV_NAME="rosetta"
CONDA_SUBDIR=osx-64 conda create -n $ENV_NAME python
conda activate $ENV_NAME
conda config --env --set subdir osx-64
or if using micromamba
:
ENV_NAME="rosetta"
CONDA_SUBDIR=osx-64 micromamba create -n $ENV_NAME python
micromamba activate $ENV_NAME
i also get this error when i install v18 of the drivers 🤷
Can't open lib '/opt/homebrew/lib/libmsodbcsql.17.dylib'
@joelharkes Why is it trying to open v17 dylib if you installed v18? What's the command that produces that error?
Idk, maybe i installed it earlier and it can't find it. But I uninstalled it yet it still looks for it. How could I debug it further?
What are the exact commands you're using?