Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install the Python development headers on Mac OS X?

For a project using Boost.Python (see this other question) I need the Python development headers containing e.g. pyconfig.h.

These are apparently missing from my system. I've installed Python 3 via Homebrew:

cls ~ $ brew info python3 python3: stable 3.3.0 http://www.python.org/ Depends on: pkg-config, readline, sqlite, gdbm /usr/local/Cellar/python3/3.2.3 (4420 files, 78M) /usr/local/Cellar/python3/3.3.0 (4843 files, 93M) * https://github.com/mxcl/homebrew/commits/master/Library/Formula/python3.rb 

I would prefer getting the headers via Homebrew, too, but I cannot find a package for them.

cls ~ $ brew search python-dev No formula found for "python-dev". Searching open pull requests... 

What are my options for installing these headers? Is there a Homebrew package?

like image 949
clstaudt Avatar asked Apr 10 '13 16:04

clstaudt


People also ask

What are Python development headers?

python-dev is the package that contains the header files for the Python C API, which is used by lxml because it includes Python C extensions for high performance. Follow this answer to receive notifications.

What is the correct way to install Python on Mac?

Install Python 3 with the Official Installer First, download an installer package from the Python website. To do that, visit https://www.python.org/downloads/ on your Mac; it detects your operating system automatically and shows a big button for downloading the latest version of Python installer on your Mac.

Where is my Python installed Mac?

The Apple-provided build of Python is installed in /System/Library/Frameworks/Python. framework and /usr/bin/python , respectively. You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software.


1 Answers

The latest Python 3 formula links a program called python3-config. You can use it to find the headers like this:

python3-config --include

On my machine, this outputs:

-I/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/include/python3.3m -I/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/include/python3.3m 

You may need to brew update && brew rm python3 && brew install python3 to enable this.

There is an equivalent program called python-config for Python 2.

like image 70
daviewales Avatar answered Oct 07 '22 13:10

daviewales