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

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.

Related

How to ensure the ipython and python3 versions match when installing them through 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!

How to install a particular version of opencv from homebrew?

How to install a particular version of OpenCV from homebrew?
I wanna install OpenCV 3
brew install opencv#3 would be what you are looking for. The formula source code is in here.

How to install OpenCV 3.4.5 in Ubuntu 14.04?

I am trying to install OpenCV 3.4.5 in Ubuntu 14.04 LTS and I need this OS for my project. I have not found any proper way to do so. I tried this: https://docs.opencv.org/3.4.5/d2/de6/tutorial_py_setup_in_ubuntu.html but cannot install the dependencies as mentioned.
Any suggestions or guide would be much appreciated.
Assuming you have Python installed, try install opencv-python which is an unofficial pre-built OpenCV package.
pip install numpy
pip install opencv-python==3.4.5
To ensure successful installation, open IDLE to check version number:
import cv2
print(cv2.__version__)

Downgrade OpenCV using HomeBrew when brew versions is deleted

I am using the latest version (1.8.2) of homebrew and I am trying to downgrade opencv 3.4.3 to 3.4.0.
I followed this answer homebrew install specific version of formula? However, the problem is that even after I brew tap homebrew/boneyard, brew versions opencv still does not work.
How can I make 'brew versions' work for homebrew 1.8.2?
If that does not work, can I manually download and set up opencv 3.4.0 to homebrew?

Install opencv 3.3.1 (previous version) with homebrew

I have an issue with not being able to use an integral piece of software due to its dependancy and being compiled with a previous version of opencv. When installing new opencv using homebrew brew install opencv I am getting the latest version 3.4. Is there anyway to install a previous version? Edit: On MacOS.
For others with the same problem:
$ brew install opencv#3
See this other answer about installing different versions of homebrew packages.
Homebrew install specific version of formula?

Resources