Loanb222 Loanb222 - 1 year ago 57
Python Question

Error Installing OpenCV with Python on OS X

I have been trying to install Open CV 3 on my mac using this tutorial but I cannot get past step three.

So after I do

brew install python

I do

nano ~/.bash_profile

And the at the bottom of the script I paste

# Homebrew
export PATH=/usr/local/bin:$PATH

After that I reload the file like this

source ~/.bash_profile

Finally I check the python like this

which python

And it prints


instead of


I have also tried edited the file in TextEdit but it has the same result.

Am I doing something wrong or is this just a bad tutorial?

Thank You in Advance!


# Setting PATH for Python 3.5
# The orginal version is saved in .bash_profile.pysave
export PATH

# Your previous /Users/UserName/.bash_profile file was backed up as /Users/UserName/.bash_profile.macports-saved_2016-07-26_at_12:50:19

# MacPorts Installer addition on 2016-07-26_at_12:50:19: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
# Homebrew
export PATH=/usr/local/bin:$PATH


Answer Source

Is there a


directory? (Version number might differ.)

Is there a



If the Cellar directory is present, but the file isn't, then Homebrew decided to be careful and not put Python in /usr/local/bin/ immediately.
You could manually do

brew link python

and see if there's now a



In your case, it appears you have some files related to Python (they might be from a Python 3 installation, can't tell), such as 2to3. You can safely overwrite them, since Python 2 also has this. Thus:

brew link --overwrite python

is fine.


Specific Python versions will always exist as python2.7, python3.5 etc (including the full path as necessary). Thus, even overwriting the python executable is safe (provided it's not the system one in /usr/bin): you should then simply be explicit which python executable to use.

Also, when using a tool like pip, you can make sure you're using the correct version by running it e.g. as

/usr/local/bin/pythnon2.7 -m pip <...>

or whatever python executable you want to install things for.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download