Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error: 'Python.h' file not found while installing opencv

Tags:

I am trying to get opencv 3.1 installed for Python on my Mac OS X 10.10.5 I'm following the steps as outlined here - http://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/

When I actually try installing opencv after all the setup, I get the following error:

.../opencv/modules/python/src2/cv2.cpp:6:10: fatal error:    'Python.h' file not found  #include <Python.h>           ^ 

I looked around StackOverflow and found that most people facing this issue are using Anaconda, which is not my case. It would be great if someone could point me in the right direction to get this fixed.

Thanks,

like image 947
Sumanth Avatar asked Mar 03 '16 17:03

Sumanth


People also ask

How do I fix Python fatal error H No such file or directory?

Python h no such file or directory is a fatal error. If you are trying to build a shared library using a C extension file, you need to install the development version of Python. For example, if you use Python 3, you need to install the python3-dev.

Does Python 3.9 support OpenCV?

No usable version of opencv for Python 3.9 #281.

What is Python H?

Python.h is nothing but a header file. It is used by gcc to build applications. You need to install a package called python-dev. This package includes header files, a static library and development tools for building Python modules, extending the Python interpreter or embedding Python in applications.

Where is Python h in Windows?

Usually, Python. h and all the header files it includes in it resides in include folder of Python's installation directory.


1 Answers

If Python.h is not found while making one of the *.cpp files, set the following ENV variable

export CPLUS_INCLUDE_PATH=/System/Library/Frameworks/Python.framework/Headers 

Please check the existence of the path in your system and make sure that Python.h is there.

like image 146
Sergey Sargsyan Avatar answered Sep 17 '22 08:09

Sergey Sargsyan