wgrib2 with Conda
Updated 11-24-24 IMPORTANT NOTE: Recent feedback from users having problems with successfully installing wgrib2 using my tutorial and Homebrew have shown that there are significant compatibility issues for those who have previously installed Conda or MiniConda on their Macs.
Basically, if you already have installed either of these two packages from Anaconda to run other geophysical and meteorological software, you may 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 may 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 if you subsequently install conda with the same shell (bash).
Homebrew installed wgrib2 and Conda are not compatible due to the Terminal $PATH conflict in .bash_profile.
However, installing conda or miniconda with the zsh shell after installing wgrib2 with bash does seem to work.
Another Solution
On a clean system, I have successfully installed wgrib2 and conda. But each was installed differently, wgrib2 with bash and conda with zsh.
I would use the zsh shell command to install conda/miniconda, not the .pkg installer and not Homebrew, after installing wgrib2 with bash. I have installed conda via the command line using zsh after installing wgrib2 with bash and Homebrew and wgrib2 will still work under either shell. but conda and wgrib2 must be installed under different shells.
That’s because conda installed with the zsh shell will modify the .zshrc file while wgrib2 installed with bash will modify the $PATH of the .bash_profile file. Having the $PATH for both conda and Homebrew in the same .zshrc or .bash_profile resource file is the problem.
Having installed wgrib2 using bash and then installing conda with .zsh, I have been able to leave zsh as the default shell and wgrib2 still works.
Yet Another Solution
Here’s another potential solution if you already have conda/miniconda previously installed: Using my tutorial, switch to bash shell from the default zsh, then install Homebrew and then before proceeding with the rest of my tutorial, edit your .bash_profile file.
• Edit your .bash_profile using a text editor or VIM with these steps—
• Select and copy all the existing text in your .bash_profile that references conda, then paste into a text editor to SAVE the text that refers to conda in a separate text file on your desktop (to be used later if you need to restore this back.)
• Delete all the text in the .bash_profile file so that it’s blank.
• Then Copy and Paste the text below in your .bash_profile and SAVE it—
If you’re on Apple Silicon, copy and paste this code into your .bash_profile file —
eval "$(/opt/homebrew/bin/brew shellenv)"
If you’re on Intel, copy and paste this code into your .bash_profile file —
eval "$(/usr/local/bin/brew shellenv)"
Then proceed with the rest of my wgrib2 installation tutorial.