找不到在Mac OS X上安装python-dev的方法

Hen*_*eca 5 python django pip virtualenv

我正在尝试安装psycopg2以用于Django.我正在使用virtualenv,当我尝试安装psycopg2时,我收到一条错误消息:

In file included from psycopg/psycopgmodule.c:27:
./psycopg/psycopg.h:30:10: error: 'Python.h' file not found with <angled> include; use "quotes" instead
#include <Python.h>
         ^~~~~~~~~~
         "Python.h"
In file included from psycopg/psycopgmodule.c:27:
In file included from ./psycopg/psycopg.h:30:
psycopg/Python.h:29:10: fatal error: 'structmember.h' file not found
#include <structmember.h>
         ^
2 errors generated.
error: command 'clang' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

我在网上发现了一些线程似乎表明这个问题的解决方案是安装python-dev.不幸的是,我发现它只适用于apt-get和yum.据我所知,它不适用于自制软件或macports.任何人都可以帮我弄清楚为什么安装失败或我如何获得psycopg2?谢谢!

编辑:我正在使用virtualenv并使用postgres应用程序.我已经安装了XCode命令行工具.

Hen*_*eca 8

事实证明我对问题的原因是错误的.这不是因为我没有Python标头,而是因为我以某种方式从homebrew python目录中删除了它们.在Freenode的Python频道聊天后,用户帮我确定了问题.只有三个文件

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/include/python2.7

所以我跑了

brew uninstall python
brew install python
Run Code Online (Sandbox Code Playgroud)

重新安装标头并解决了问题!