How to ensure the ipython and python3 versions match when installing them through homebrew? - homebrew

Currently, the default version of python3 installed through homebrew is 3.10.9. However, the default version of ipython depends on python 3.11.1, which is automatically installed with homebrew.
The problem is that if I install a package via pip, it will not be recognized in ipython because of how homebrew manages different python versions.
Is it possible to ensure ipython uses the same version of python as homebrew's default version?
I understand there are other solutions like using pyenv to manage different versions of python, but I am looking for a solution that only requires homebrew.
I have tried the command brew unlink python#3.10, but it removes the python3 symbolic link, which means I have to update the symbolic link manually to point to the desired version.
Thanks!

Related

Install Libomp - Homebrew is not being found on my terminal

Im trying to install libomp on my mac using the following command:
brew install libomp
But everytime I get an error like this:
Warning: No available formula with the name "libomp".
==> Searching for similarly named formulae and casks...
Error: No formulae or casks found for libomp.
I already uninstall and install Homebrew twice, uninstall/install and updated the lightgbm package, and nothing seems to work.
I was able to install other packages so is not a problem with my computer or anything like that.
Does anyone know how can I fix that?
Run the following to ensure your Homebrew is up to date.
brew update
Then install libomp like this
brew install libomp
and updated the lightgbm package
I'm not sure if this means the lightgbm Python package, the lightgbm CLI installed via Homebrew, or something else...but either way, the presence of those things should not impact whether or not Homebrew is able to install libomp on your system.

How are different package versions supported in homebrew?

homebrew supports the installation of different versions of a package.
Homebrew install specific version of formula?
But I don't see different versions specified in homebrew formulas.
https://github.com/Homebrew/homebrew-core/blob/master/Formula/bash.rb
Does anybody know how the support of different versions of a package is implemented in homebrew? Thanks.
There is at least three different ways package versions are supported by Homebrew.
1) With brew switch, you can switch back to a version of a package you already installed. For example typing brew switch ansible, I obtain:
ansible installed versions: 2.7.5, 2.7.6
using brew switch ansible 2.7.5, I can switch back to an old version, but this works only for versions that have been already installed.
2) With versioned formulas, you can choose an old version of MySQL with brew install mysql#5.5 or brew install mysql#5.6. This works because there is the corresponding formulas: mysql#5.5.rb and mysql#5.6.rb.
3) You can use the git history to go back to any version of a formula, read this question/answer for details: Install older version of Pandoc (<2) using homebrew

Homebrew does not upgrade pyenv

I'm trying to upgrade pyenv with homebrew for getting new Python releases.
Here is the problem:
$ brew upgrade pyenv
Error: pyenv 1.2.7 already installed
Is there a kind of update latency in homebrew package versioning? I am aware of the existence of other ways to install pyenv, but I'd like to use homebrew.
pyenv 1.2.8 is not yet officially released.
On the master branch the last tag is 1.2.7.
The commit you mentioned in your question is in preparation for release 1.2.8.
Version 1.2.7 is here https://github.com/pyenv/pyenv/tree/v1.2.7
Version 1.2.8 should be here https://github.com/pyenv/pyenv/tree/v1.2.8 but nothing is there (yet).
Verify which pyenv your system is using.
I thought I had this issue but then realized I had two different installs on my computer and my system was not actually using the brew installed pyenv --version.
Grepping my shell history, I saw that at some point I installed pyenv with curl using pyenv-installer for some reason. The command I found in my history was curl https://pyenv.run | bash. I followed the pyenv-installer directions to uninstall. Make sure to restart your shell once you uninstall!
I then reinstalled pyenv with brew. brew reinstall pyenv though I'm not sure if that's necessary.
I now see the newer versions of python available for install with pyenv install --list

Homebrew - Python3.7 replace Python3.6.5 if you brew install opencv2

I installed Python 3.6 using a direct link (brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rbbrew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb), since Brew now install by default 3.7 version, if I use brew install python3
Although if I install OpenCv2 from Brew; I get also Python 3.7, and that version get linked as default, moving 3.6 aside. I did try to brew link the previous version, but then when I import cv2, I get an error that the package does not exist.
If I run brew install opencv It tell me that the packages are already installed; so Python 3.6 can't import it, but 3.7 can.
I thought it is a problem with PATH but even that does not seem to have effect.
is there a way to tell brew to not update python when installing new packages? I am OK with 3.7 being installed; but I would like to be able to use OpenCV2 from both; while now I can only import it using 3.7 and not 3.6
brew pin python will prevent it from being upgraded. OpenCV will need to be installed with --build-from-source since the bottle is built and tested against the latest python formula.

brew doctor warnings - delete or ignore?

After I installed Homebrew,
Then I try the brew doctor command, there comes warnings:
Could I know the reasons and How to fix it? Could I just ignore these warnings?
The files reported by brew doctor are added by a software (that you manually installed before installing Homebrew) that uses a library for the Tcl/Tk language.
Homebrew also provides a library for Tcl/Tk and the existing files will conflict with those installed by Homebrew if you install a package that requires the Tcl/Tk library.
You don't have to worry for now and, very important, don't try to "fix" anything (especially don't remove files).
What you can do to "fix" it is to find out what program installed those files (it was not installed using the App Store, you installed it manually) and see if Homebrew provides it. If it is a macOS GUI application then Homebrew doesn't provide it (it contains only command line applications, no GUI) but Homebrew Cask might do it.
Use
$ brew search app
or
$ brew cask search app
If you are lucky and you find it and you are pleased with the version provided by Homebrew then you can uninstall the application using the uninstaller it hopefully provides then reinstall it using Homebrew (or Homebrew Cask).
You can run brew doctor between uninstall and reinstall to make sure the uninstaller removed all the files listed in the output of brew doctor now.
As written at the beginning of brew doctor's output, you can safely ignore these warnings if everything you use Homebrew for works fine.

Resources