Installing pyodbc and unixodbc on a mac - macos

I've seen Pypyodbc: Can't open lib 'FreeTDS' : file not found") error when trying to connect to SQL server, but. that's 7 years old, and doesn't seem to be working for me, possibly because brew appears to be putting things in different places now?
I've used brew to install unixodbc, it's in /opt/homebrew/Cellar.
When I do pip install pyodbc, it appears to work, but I get:
connection = pyodbc.connect(connection_string)
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libtdsodbc.so' : file not found (0) (SQLDriverConnect)")
which is obviously wrong, because libtdsodbc is in /opt/homebrew/lib
I tried editing odbcinst.ini, but I'm not sure where that's supposed to live. There wasn't one in /etc, or a /etc/unixODBC directory... and when I create either one, the don't seem to be read, because it still complains about /usr/local/lib...
ETA: This is on a new Macbook, so on one of the new M1 chips.

Note: This is a BAD answer in the hopes of attracting a good one, but it technically seems to be working.
Homebrew for M1 installs everything in /opt/homebrew. Everything else expects things in /usr/local. On a new computer, /usr/local/lib didn't even exist. So I did
sudo ln -s /opt/homebrew/lib /usr/local/lib
THIS IS VERY BAD AND I KNOW IT But it's the only way I've figured out currently to deal with the problem. Maybe something hasn't caught up to M1? I'm not sure.

BETTER solution:
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/opt/homebrew/lib

There is a pull request that has been pretty much ignored for 13 months now by the pyodbc maintainer: https://github.com/mkleehammer/pyodbc/pull/870
You can install the forked version with this command (might need to uninstall the previous version or add extra arguments to force reinstall)
python3 -m pip install git+git://github.com/Aloisius/pyodbc.git#m1-homebrew

Related

bash: /home/linuxbrew/.linuxbrew/bin/go: Bad address

I did an brew upgrade and afterwards keep getting an bad address error.
Tried to uninstall/reinstall everything, but cant figure out what is the problem.
bash: /home/linuxbrew/.linuxbrew/bin/go: Bad address
Im new to terminal and linux, so all advice is welcome.
I tried brew doctor. It says "No developer tools installed." and after i 'brew install gcc' it says gcc is already installed and up-to-date.
Use the official Go installation:
Go: Download and install
For full support, avoid OS package managers, Homebrew, and so forth.
First, remove any previous installations by other methods, for example, Homebrew.
Little late, but this post was a suggestion for me when I ran into a similar issue with Go and Brew.
When Brew updates the version of Go (1.19.3 -> 1.19.5 in my case) that it is providing, for some reason it does not correctly update the GOROOT environment varaible. Correcting the value of the variable fixed the issue for me.
export GOROOT=/home/linuxbrew/.linuxbrew/Cellar/go/<go_version>/libexec
# example
export GOROOT=/home/linuxbrew/.linuxbrew/Cellar/go/1.19.5/libexec

GDL not found after installing with homebrew

I used brew install GDL. The install was completed, but once I try to use GDL, it says " command not found: gdl".
I used "which gdl", but still can't be located. I tried reinstalling GDL via brew, but same error.
I tried changing the directory to the folder where brew installed GDL, but no luck either.
I looked through my other compilers and those are saved into bin, while GDL is not (if that's relevant at this point).
Anything will help!
If the intention was to install GNU Data Language, please try installing gnudatalanguage from homebrew-science: https://github.com/brewsci/homebrew-science/blob/master/Formula/gnudatalanguage.rb

Fixing m4 on MAC OS 10.14.5

I'm having an issue with pecl which is erring out saying phpize had failed.
The problem ultimately seems to be with m4. Error is autom4te: need GNU m4 1.4 or later: /Applications/MAMP/Library/bin/m4
When I run "which m4" I get /Applications/MAMP/Library/bin/m4
However, any command I try to run with m4 like "m4 --version" I get the following:
Abort trap: 6
I can't find a good explanation of that error, but I'm guessing something is corrupted with m4, but I can't figure out how to fix this on a Mac. Do I just download a newer version and run configure, make and make install? Just a little nervous since I have somewhat limit Mac experience.
I've fixed similar issue by executing brew reinstall m4.
In addition to a "brew (re)install m4", I had to temporarily remove "/Applications/MAMP/Library/bin" from my PATH. After that this worked for me.

ImageMagick + El Capitan Unable to Locate Module

UPDATE: Solved with the solution here
I have spent the better part of my day trying to get ImageMagick to work with Grunt, with no luck. Grunt seems to be okay, but ImageMagick not so much, even though I've run the test on ImageMagick.org to make sure that it's installed correctly (I used HomeBrew for the install).
I get this error when trying to run a task:
Warning: Command failed: identify: unable to load module
'/usr/local/Cellar/imagemagick/6.9.2-4/lib/ImageMagick//modules-
Q16/coders/jpeg.la': file not found # error/module.c/OpenModule/1300.
identify: no decode delegate for this image format 'JPEG' #
error/constitute.c/ReadImage/501.
I've tried the solutions here and here, but none of them have helped.
(FYI I'm new to using the command line.)
Help?
As with any homebrew problem, I would suggest you run
brew doctor
first, to try and sort things out. It is an excellent diagnosis tool.
Now, to your specific problem... mmmm... the /opt/X11 part of your error message worries me because homebrew installs in /usr/local/bin and /usr/local/Cellar so your ImageMagick should not be looking anywhere in /opt at all. I guess you have installed freetype via MacPorts or some method other than homebrew.
I would suggest you install the freetype stuff using homebrew, i.e.
brew install freetype
Then I would suggest uninstalling any other freetype stuff you have installed any other way. Finally, I would suggest you check your PATH environment variable and make it point to /usr/local/bin before anything in /opt. You will need to log out and back in for the new PATH to take effect - you can check your PATH like this:
echo $PATH
and change it by editing $HOME/.profile if you need to.
The homebrew version of freetype provides version 19 of the library and is therefore compatible with the homebrew ImageMagick version.
Also, I am a little disconcerted by the X11 part in your error message - modern Macs don't really use X11 any more and it doesn't ship with OSX. Let's see if the above ideas sort you out before worrying about that too much though - unless you know, and can say for sure, that you need X11.

OSX Homebrew error: uninitialized constant MACOS

I've searched around a bit and can't seem to find any record of anyone else with this problem.
Whenever I try to run
$ brew update
I am rewarded with
/usr/local/bin/brew:34: uninitialized constant MACOS (NameError)
This isn't my machine and I normally develop on Linux systems so this is all a bit odd to me.
Any help would be greatly appreciated! Please tell me if there is any additional info I should provide. Again, I'm not used to homebrew or OSX.
EDIT
at the request of JameA
xiao:~ patrick$ brew doctor
/usr/local/bin/brew:34: uninitialized constant MACOS (NameError)
xiao:~ patrick$ brew --config
/usr/local/bin/brew:34: uninitialized constant MACOS (NameError)
...Not sure I like this whole "here, use this macbook for the project, it works better" thing...
I'm pretty sure the root cause of this is a failed upgrade attempt to Homebrew 0.9.5 from a much earlier version. Basically, if you run brew update as opposed to sudo brew update a portion of files are updated, while others are not. Here's what worked for me:
Edit /usr/local/bin/brew (it's just a Ruby file, not a compiled binary, so any text editor will do). You'll find a block like:
if MACOS and MACOS_VERSION < 10.5
abort <<-EOABORT.undent
Homebrew requires Leopard or higher. For Tiger support, see:
https://github.com/mistydemeo/tigerbrew
EOABORT
end
Comment this out. Even if you don't know Ruby, you can probably intuit what this is doing—it's checking to see if you have a current version of OSX. Assuming that you do in fact have this version, this sanity check isn't necessary. Brew is still broken, but at least now it will load far enough to give error messages.
Run sudo brew update, spoiler alert: it fails, but this time with a meaningful error message:
$ brew update
error: Your local changes to the following files would be overwritten by merge:
[giant list of files here]
Well, today I learned that brew update is just a wrapper for git pull because anyone who has worked with git knows that error message. We can fix this too.
Switch into the homebrew git repository with cd /usr/local and give the command git reset --hard FETCH_HEAD.
This piece found here.
Give the command sudo brew update. Homebrew should now update successfully and work properly!
Once the system is working again, you can actually kind of see why an error like this would have occurred. For one, usr/local/bin/brew has been completely rewriten and isn't even Ruby anymore, and most of its configuration has been moved into /usr/local/Library/brew.rb which no longer uses the constants MACOS or MACOS_VERSION constants, as they have been replaced by the more object oriented OS.mac and MacOS.version.
The MACOS constant is set in globals.rb. It seems like you may have a borked installation of Homebrew.
Check the output of brew doctor for any suggestions.
If that doesn't help please update with the results of brew --config.
If all else fails you may want to try re-installing Homebrew.
UPDATE:
Since this was a previous user's machine make sure your user is the owner of /usr/local and everything within. Fix it with sudo chown -R $USER /usr/local.
I had a similar issue, when I Killed an install mid-way with Ctrl-D.
Post that whenever I tried installing anything it gave the following error
uninitialized constant Homebrew::CLI::Parser::ARGV_WITHOUT_MONKEY_PATCHING
As a fix, I went to the directory I had where homebrew was installed, and reset the HEAD.
cd /usr/local/Homebrew
git status
git checkout .
And then it started working magically.
I had a similar error with a "borked" installation of brew. I removed the small 5 line block of code in the /usr/local/bin/brew script starting with the MACOS line. That did the trick to allow me to uninstall and eventually reinstall it.
In addition to Matt Korostoff's answer.
On point 3 (resetting the repo), for recent version of Homebrew, the repo is no longer /usr/local, do cd "$(brew --repo)" instead.

Resources