Sum*_*nth 18 python macos opencv
我试图在我的Mac OS X 10.10.5上为Python安装opencv 3.1我遵循这里概述的步骤 - http://www.pyimagesearch.com/2015/06/15/install-opencv-3- 0和-蟒-2-7-ON-OSX /
当我在所有设置之后实际尝试安装opencv时,我收到以下错误:
.../opencv/modules/python/src2/cv2.cpp:6:10: fatal error:
'Python.h' file not found
#include <Python.h>
^
Run Code Online (Sandbox Code Playgroud)
我环顾了StackOverflow,发现大多数人都在使用Anaconda,这不是我的情况.如果有人能指出我正确的方向来解决这个问题,那就太棒了.
谢谢,
小智 13
如果在制作其中一个*.cpp文件时未找到Python.h,请设置以下ENV变量
export CPLUS_INCLUDE_PATH=/System/Library/Frameworks/Python.framework/Headers
Run Code Online (Sandbox Code Playgroud)
请检查系统中是否存在路径,并确保Python.h存在.
pol*_*ise 11
我正在使用El Capitan但我不认为Python头的路径应该有太大差异.我发现我的:
/System/Library/Frameworks/Python.framework/Headers/Python.h
Run Code Online (Sandbox Code Playgroud)
你可以尝试运行:
export C_INCLUDE_PATH=/System/Library/Frameworks/Python.framework/Headers
Run Code Online (Sandbox Code Playgroud)
然后尝试剩余的步骤.
这个问题似乎是关于macOS中默认集成的Python2,其Python.h头文件位于地址:
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h
Run Code Online (Sandbox Code Playgroud)
Python 版本可能会根据您使用的 macOS 版本而变化。但是,如果您已经使用 Hombrew 安装了 Python3(您可能应该这样做),那么您可能会在如下路径中找到头文件:
/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/Python.h
Run Code Online (Sandbox Code Playgroud)
brew取决于您安装的Python3 版本。同样,还有许多其他的可能性可以在 mac 上获取 Python(例如,anaconda、intel python、pypy...凡是你能想到的)。查找特定路径的最佳方法Python.h是使用以下命令搜索整个设备:
sudo find / -iname "Python.h"
Run Code Online (Sandbox Code Playgroud)
然后就可以运行命令了
export C_INCLUDE_PATH="<path/to/the/specific/header/folder>"
Run Code Online (Sandbox Code Playgroud)
在你的 bash 终端中,或者将其添加到 中~/.bash_profile以使其永久存在。
您可能还想检查 MakeFile(或软件使用的其他工具,例如 cmake...)以查看Python.h它需要什么版本以及在什么位置。它正在期待它。
跑步
brew install python
Run Code Online (Sandbox Code Playgroud)
或者
brew upgrade python
Run Code Online (Sandbox Code Playgroud)
完成此操作后,您想要安装的所有内容(在我的例子中是vim)都会成功。
| 归档时间: |
|
| 查看次数: |
20043 次 |
| 最近记录: |