简体   繁体   English

Homebrew安装的OpenCV 3.0没有链接到Python

[英]Homebrew installation of OpenCV 3.0 not linking to Python

When I install OpenCV 3.0 with Homebrew, it gives me the following directions to link it to Python 2.7: 当我用Homebrew安装OpenCV 3.0时,它给了我以下指示将它链接到Python 2.7:

If you need Python to find bindings for this keg-only formula, run: 如果您需要Python来查找此仅keg公式的绑定,请运行:
echo /usr/local/opt/opencv3/lib/python2.7/site-packages >> /usr/local/lib/python2.7/site-packages/opencv3.pth echo /usr/local/opt/opencv3/lib/python2.7/site-packages >> /usr/local/lib/python2.7/site-packages/opencv3.pth

While I can find the python2.7 site packages in opencv3, no python34 site packages were generated. 虽然我可以在opencv3中找到python2.7站点包,但是没有生成python34站点包。 Does anyone know how I can link my OpenCV 3.0 install to Python 3? 有谁知道如何将我的OpenCV 3.0安装链接到Python 3?

It's weird that there is no concise instruction for installing OpenCV 3 with Python3. 奇怪的是,没有关于使用Python3安装OpenCV 3的简明指令。 So, here I make it clear step-by-step: 所以,我在这里一步一步地说清楚:

  1. Install Homebrew Python 3.5: brew install python3 安装Homebrew Python 3.5: brew install python3
  2. Tap homebrew/science: brew tap homebrew/science 点击自制/科学: brew tap homebrew/science
  3. Install any Python3 packages using pip3 . 使用pip3安装任何 Python3包。 This will create the site-packages folder for Python3 For example: pip3 install numpy 这将为Python3创建site-packages文件夹例如: pip3 install numpy

  4. Then install OpenCV3 brew install opencv3 --with-python3 然后安装OpenCV3 brew install opencv3 --with-python3

  5. Now you can find the site-packages folder created in Step 2. Just run the following command to link Opencv3 to Python3: echo /usr/local/opt/opencv3/lib/python3.5/site-packages >> /usr/local/lib/python3.5/site-packages/opencv3.pth 现在您可以找到在步骤2中创建的site-packages文件夹。只需运行以下命令将Opencv3链接到Python3: echo /usr/local/opt/opencv3/lib/python3.5/site-packages >> /usr/local/lib/python3.5/site-packages/opencv3.pth

You may have to change the above command correpondingly to your installed Homebrew Python version (eg 3.4). 您可能必须相应地更改上面的命令到您安装的Homebrew Python版本(例如3.4)。

You need to install opencv like brew install opencv3 --with-python3 . 你需要像brew install opencv3 --with-python3一样安装opencv。 You can see a list of options for a package by running brew info opencv3 . 您可以通过运行brew info opencv3查看包的选项列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM