在 Mac - VirtualEnv 上安装 OpenCV(更新 bash_profile 和 pip 错误)

Install OpenCV on Mac - VirtualEnv (Updated bash_profile and pip error)

我正在尝试使用 this 教程在我的 Mac (OS X 10.11.3) 上安装 OpenCV,因为它使用了 VirtualEnv,这是一种确保一致性的方法开发中。

我跳过了第 1 步和第 2 步,因为我已经有了 Xcode 和 Homebrew。第 3 步运行良好(按照说明更新 ~/.bash_profile 后):

User:~ user$ brew update
Already up-to-date.
User:~ user$ source ~/.bash_profile
User:~ user$ which python
/usr/local/bin/python
User:~ user$ 

问题出在第4步:

User:~ user$ pip install virtualenv virtualenvwrapper
-bash: /usr/local/bin/pip: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory
User:~ user$

这可能是因为我在本地垃圾箱中添加了第 3 步中的 ~/.bash_profile

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

这基本上意味着我无法从该位置访问 pip,但是当我尝试在本地安装它时(在 ~/.bash_profile 中添加了上述行),它说:

User:~ user$ brew install pip
Error: No available formula with the name "pip" 
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can install
pip via the instructions at:

  https://pip.readthedocs.org/en/stable/installing/#install-pip
User:~ user$

如何使用第 3 步更新后的 ~/.bash_profile 访问 pip?谢谢!

好的,我找到问题了。

我遇到了与 this Whosebug 问题相同的错误,所以我 运行 推荐的

brew link python

遇到了与this Whosebug问题相同的错误,所以我运行推荐

brew link --overwrite python

这似乎解决了问题并允许我在首先访问 Homebrew 包时 运行 pip。