Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Install-From-Source-Guide: outdated instructions (Mac) #114

Open
TheMrIron2 opened this issue Aug 5, 2019 · 14 comments
Open

Install-From-Source-Guide: outdated instructions (Mac) #114

TheMrIron2 opened this issue Aug 5, 2019 · 14 comments

Comments

@TheMrIron2
Copy link

TheMrIron2 commented Aug 5, 2019

In the dependencies section, it says:

macOS:

Install Homebrew, then brew install ffmpeg and brew install homebrew/science/opencv --with-ffmpeg.

The homebrew/science branch was deprecated as all formulae were moved elsewhere. The closest package I could find by name was opencv@2 by simply doing brew install opencv@2 however --with-ffmpeg is an invalid option when I tried substituting with this.

(edit: overlooked package opencv because I'm stupid but same invalid option error thrown)

@TheMrIron2 TheMrIron2 changed the title Install-From-Source-Guide: outdated instructions Install-From-Source-Guide: outdated instructions (Mac) Aug 5, 2019
@andrewmackenzie
Copy link

andrewmackenzie commented Sep 11, 2019

I don't have it working yet, but I was able to get butterflow to install without errors on a MacBook Pro running Mojave.

I added these lines to my ~/.profile:
export PATH="/usr/local/opt/opencv@2/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/opencv@2/lib"
export CPPFLAGS="-I/usr/local/opt/opencv@2/include"

Then ran the instructions found in Install from Source Guide.

But running the snippet at the end showed that five of the ffmpeg flags were not available. That might be my issue...

@brodyhoskins
Copy link

brodyhoskins commented Sep 16, 2019

@andrewmackenzie Try installing ffmpeg from https://github.com/varenc/homebrew-ffmpeg — I cannot confirm if this works as it doesn't work on macOS Catalina yet.

@thure
Copy link

thure commented Jan 31, 2020

I see references to butterflow all over the internet when frame interpolation comes up, so it's a bit surprising it's not just an installable Homebrew formula. If someone can get this working on a contemporary version of macOS, probably worthwhile to make it a formula.

@GusDenton
Copy link

I need help with the very last stage of this. I am not a software engineer of any kind so my nix skills aren't great, but I have managed by hook and crook to get to the last part of the process.
When I cloned the butterflow repo I made a directory in ~/ home folder called Gitrepos and cloned butterfly in there. So I am at the point of doing python setup.py install but it cannot find things.
/Users/angus/Gitrepos/butterflow/butterflow/ocl.cpp:9:10: fatal error: 'opencv2/core/core.hpp' file not found #include <opencv2/core/core.hpp>
My $PATH environment variable has
usr/local/opt/opencv@2/bin: and usr/local/opt/opencv@2/include in it.
usr/local/opt/opencv@2 is a Symlink created when opencv@2 is installed by Hombrew and I can traverse the file structure from the command line and get to opencv2/core/core.hpp file no problems ? what could be happening ?
Gus

@ManxStef
Copy link

ManxStef commented Jun 4, 2020

Here's a step-by-step of worked for me on macOS 10.15 Catalina:

Install the Xcode commandline tools if you need to
xcode-select --install

note that opencv@2 depends on ffmpeg now so it gets installed automatically - see https://formulae.brew.sh/formula/opencv@2
brew install opencv@2

Install pip, which'll then let us install virtualenv
sudo easy_install pip
pip install virtualenv

Note that it'll give you the following info, which we can ignore for now
WARNING: The script virtualenv is installed in '/Users/yourusername/Library/Python/2.7/bin'
which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

cd to wherever you want to put your code, e.g. cd ~, then clone the butterflow source
git clone https://github.com/dthpham/butterflow.git

Create the virtualenv - we'll just refer to the newly-install virtualenv binary directly instead of adding it to our PATH like the warning above says. Note that python has been renamed to python2 and python3 in Catalina, as far as I know, so we want virtualenv to use python2
~/Library/Python/2.7/bin/virtualenv -p /usr/bin/python2 butterflow

Navigate into the folder
cd butterflow

Tell butterflow where the homebrew python site-packages are by using a .pth file
echo "$(brew --prefix)/lib/python2.7/site-packages" > lib/python2.7/site-packages/butterflow.pth

activate the virtualenv
source bin/activate

now we're inside the virtualenv, set the compile flags so the clang compiler knows where things are

export LDFLAGS="-L/usr/local/opt/opencv@2/lib -L/usr/local/opt/openblas/lib"
export CPPFLAGS="-I/usr/local/opt/opencv@2/include"
export PKG_CONFIG_PATH="/usr/local/opt/opencv@2/lib/pkgconfig"
export PYTHONPATH=$PYTHONPATH:$(brew --prefix)/lib/python2.7/site-packages

OK, we're hopefully ready to install! -
sudo python2 setup.py install

test that it works
butterflow --help

exit the virtualenv
deactivate

NOTE: to use butterflow outside of the virtualenv environment, you'll need to set the PYTHONPATH permanently for your shell, e.g. something like:
echo "export PYTHONPATH=$PYTHONPATH:$(brew --prefix)/lib/python2.7/site-packages" >> ~/.bash_profile

Hope that helps somebody!

@ManxStef
Copy link

ManxStef commented Jun 4, 2020

Oh, I forgot to mention. If you can't compile because of a ImportError: No module named _winreg warning or something like that (winreg doesn't exist on non-Windows platforms, so it's not too surprising that it can't be found) edit the butterflow/__init__.py file and blank the whole thing out. I changed mine to look like this, though it can probably be totally empty:

#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import os
import sys

Then hopefully it should compile fine on macOS.

@niskander
Copy link

@ManxStef thanks, these worked for me!

If you get an error with import cv2 after all this, check #10 (all the way from 2015!)

@markphd
Copy link

markphd commented Nov 25, 2020

I wonder if anyone has successfully installed this in OSX (10.14.6 (18G103)). I successfully linked the modules required but I get too many error and warning during installation.

/usr/local/opt/opencv@2/include/opencv2/opencv2/core/core.hpp:48:10: error: #include nested too deeply
#include "opencv2/core.hpp"
         ^
In file included from /Users/m/Labs/butterflow/butterflow/ocl.cpp:10:
/usr/local/include/opencv2/core/ocl.hpp:631:5: error: unknown type name 'CV_DEPRECATED'
    CV_DEPRECATED bool read(const String& buf, const String& buildflags); // removed, use ProgramSource instead
    ^
/usr/local/include/opencv2/core/ocl.hpp:631:19: error: expected member name or ';' after declaration specifiers
    CV_DEPRECATED bool read(const String& buf, const String& buildflags); // removed, use ProgramSource instead
    ~~~~~~~~~~~~~ ^
/usr/local/include/opencv2/core/ocl.hpp:632:5: error: unknown type name 'CV_DEPRECATED'
    CV_DEPRECATED bool write(String& buf) const; // removed, use getBinary() method instead (RAW OpenCL binary)
    ^
/usr/local/include/opencv2/core/ocl.hpp:632:19: error: expected member name or ';' after declaration specifiers
    CV_DEPRECATED bool write(String& buf) const; // removed, use getBinary() method instead (RAW OpenCL binary)
    ~~~~~~~~~~~~~ ^
/usr/local/include/opencv2/core/ocl.hpp:633:5: error: unknown type name 'CV_DEPRECATED'
    CV_DEPRECATED const ProgramSource& source() const; // implementation removed
    ^
/usr/local/include/opencv2/core/ocl.hpp:633:19: error: expected member name or ';' after declaration specifiers
    CV_DEPRECATED const ProgramSource& source() const; // implementation removed
    ~~~~~~~~~~~~~ ^
/usr/local/include/opencv2/core/ocl.hpp:634:5: error: unknown type name 'CV_DEPRECATED'
    CV_DEPRECATED String getPrefix() const; // deprecated, implementation replaced
    ^
/usr/local/include/opencv2/core/ocl.hpp:634:25: error: expected ';' at end of declaration list
    CV_DEPRECATED String getPrefix() const; // deprecated, implementation replaced
                        ^
                        ;
/usr/local/include/opencv2/core/ocl.hpp:635:5: error: unknown type name 'CV_DEPRECATED'
    CV_DEPRECATED static String getPrefix(const String& buildflags); // deprecated, implementation replaced
    ^
/usr/local/include/opencv2/core/ocl.hpp:635:19: error: expected member name or ';' after declaration specifiers
    CV_DEPRECATED static String getPrefix(const String& buildflags); // deprecated, implementation replaced
    ~~~~~~~~~~~~~ ^
/Users/m/Labs/butterflow/butterflow/ocl.cpp:58:11: error: unknown type name 'DeviceInfo'
    const DeviceInfo& currentDevice = Context::getContext()->getDeviceInfo();
          ^
/Users/m/Labs/butterflow/butterflow/ocl.cpp:58:48: error: no member named 'getContext' in 'cv::ocl::Context'
    const DeviceInfo& currentDevice = Context::getContext()->getDeviceInfo();

I wonder if there is any workaround available for OSX. 🤔

@niskander
Copy link

yes as mentioned I’ve successfully installed it on OS X with the steps above

@kirkegross
Copy link

kirkegross commented Jan 10, 2021

Hi Thanks for these steps @ManxStef ! I followed it successfully until I got this error after running this command: sudo python2 setup.py install
Error:
/butterflow/butterflow/ocl.cpp:9:10: fatal error:
'opencv2/core/core.hpp' file not found
#include <opencv2/core/core.hpp>
^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1

Does anyone know how to fix that?

@balchlab
Copy link

balchlab commented Apr 2, 2021

Bump, same error here - trying to install it on MacOS BigSur:

fatal error:
'opencv2/core/core.hpp' file not found

I followed @ManxStef directions up to

python2 setup.py install

Anyone could help?
Thanks!

@wednesdayayay
Copy link

I'm also on mac big sur and am stuck on "fatal error: 'opencv2/core/core.hpp' file not found"
I feel like I've run around the problem a bunch and just can't get my head around the issue
any help would be appreciated

@Fire-
Copy link

Fire- commented Jun 9, 2021

even with all of the other steps ( thanks @ManxStef ) I still needed to brew link opencv@2 to get beyond fatal error: 'opencv2/core/core.hpp' file not found

cc: @kirkegross @balchlab @wednesdayayay

@metacollin
Copy link

The issue is that when one runs sudo python2 setup.py install, setup.py can no longer find the environment variables because the shell id has changed (due to sudo).

However, on Big Sur, one no longer needs to use sudo here. However, and I am not entirely clear how or why this has happened, but in my case, I get a new error, which is :

/Users/<redacted>/butterflow/butterflow/ocl.cpp:10:10: fatal error: 'opencv2/core/ocl.hpp' file not found

It seems ocl.hpp has mysteriously changed locations and is now found in opencv2/ocl/ocl.hpp.

Guide to compiling for macOS Big Sur:

Big thanks to @ManxStef, the first part of this guide is a literal copy and paste from his Catalina guide.

Install the Xcode commandline tools if you need to
xcode-select --install

note that opencv@2 depends on ffmpeg now so it gets installed automatically - see https://formulae.brew.sh/formula/opencv@2
brew install opencv@2

Install pip, which'll then let us install virtualenv
sudo easy_install pip
pip install virtualenv

Note that it'll give you the following info, which we can ignore for now
WARNING: The script virtualenv is installed in '/Users/yourusername/Library/Python/2.7/bin'
which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

cd to wherever you want to put your code, e.g. cd ~, then clone the butterflow source
git clone https://github.com/dthpham/butterflow.git

Create the virtualenv - we'll just refer to the newly-install virtualenv binary directly instead of adding it to our PATH like the warning above says. Note that python has been renamed to python2 and python3 in Big Sur, as far as I know, so we want virtualenv to use python2
~/Library/Python/2.7/bin/virtualenv -p /usr/bin/python2 butterflow

Navigate into the folder
cd butterflow

Tell butterflow where the homebrew python site-packages are by using a .pth file
echo "$(brew --prefix)/lib/python2.7/site-packages" > lib/python2.7/site-packages/butterflow.pth

activate the virtualenv
source bin/activate

now we're inside the virtualenv, set the compile flags so the clang compiler knows where things are

export LDFLAGS="-L/usr/local/opt/opencv@2/lib -L/usr/local/opt/openblas/lib"
export CPPFLAGS="-I/usr/local/opt/opencv@2/include"
export PKG_CONFIG_PATH="/usr/local/opt/opencv@2/lib/pkgconfig"
export PYTHONPATH=$PYTHONPATH:$(brew --prefix)/lib/python2.7/site-packages

Now, because of a mysterious relocation of an opencv@2 header file, we need to make a symbolic link to where butterflow expects it to be:

ln -s /usr/local/opt/opencv@2/include/opencv2/ocl/ocl.hpp /usr/local/opt/opencv@2/include/opencv2/core/ocl.hpp

Finally, we are ready to install. Hold onto your butt:
python2 setup.py install

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests