Basically, if you already have installed either of these two packages from Anaconda to run other geophysical and meteorological software, you will find that following my tutorial (which uses Homebrew) may not work.
Conda/Miniconda create an incompatible $PATH in your .bash_profile from the $PATH needed using my tutorial and Homebrew.
There is a simple solution: use conda to install wgrib2. Use this link to install wgrib2 using conda instead following my tutorial that uses Homebrew.
After you install wgrib2 using conda, you will need to run wgrib2 in a conda environment instead of the regular Terminal bash shell.
Also note that subsequent installation of conda or miniconda AFTER installing wgrib2 with my tutorial (using Homebrew) will break your previous install of wgrib2.
Homebrew installed wgrib2 and Conda are not compatible due to the Terminal $PATH conflict.
Over the years, changes in MacOS, wgrib2, and Homebrew have at times complicated installation and compilation of wgrib2. This page discusses various insights learned from my having installed wgrib2 on a 2008 Mac with El Capitan through an M3 iMac. My response to readers installation challenges and questions have further enhanced my understanding of how things go right …or wrong with installation.
Here are some insights that you might find helpful—
Incorrect .bash_profile $PATH variable
April 2024/ Some minor challenges have emerged with Apple Silicon Macs and Homebrew.
Previously, Homebrew used this directory on Intel Macs—
/usr/local/bin
to install its symlinks. As a result, your .bash_profile required a standard
path, something like this—
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
With Apple Silicon Macs, Homebrew now installs here—
/opt/homebrew/bin
As a result, your .bash_profile will have this PATH—
eval "$(/opt/homebrew/bin/brew shellenv)"
Unfortunately, people who moved their system from an older Intel Mac to an Apple Silicon Mac (using Migration Assistant) will find that a /usr/local/bin directory may still be in use. even though Homebrew will install the wgrib2 dependencies in /opt/homebrew/bin.
Without a .bash_profile that has both instructions—
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
eval "$(/opt/homebrew/bin/brew shellenv)"
wgrib2 may give an error “can’t find xxxx library” during compilation.