找不到在Mac OS X上安装python-dev的方法 [英] Can't find a way to install python-dev on Mac OS X

查看:969
本文介绍了找不到在Mac OS X上安装python-dev的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装用于Django的psycopg2.我正在使用virtualenv,当我尝试安装psycopg2时出现错误消息:

I'm trying to install psycopg2 for use with Django. I'm using a virtualenv and when I try to install psycopg2 I get an error which says:

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

我在网上发现了一些线程,这似乎表明解决此问题的方法是安装python-dev.不幸的是,我发现它仅适用于apt-get和yum.据我所知,它不适用于自制软件或Macports.谁能帮助我确定为什么安装失败或如何获得psycopg2?谢谢!

I found a few threads online that seemed to suggest that the solution to this problem is to install python-dev. Unfortunately, I've only found it available for apt-get and yum. It's not available for homebrew or macports as for as I know. Can anyone help me figure out either why the installation fails or how I can get psycopg2? Thanks!

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

I'm using a virtualenv and using the postgres app. I have the XCode command line tools installed already.

推荐答案

因此,事实证明我错了.这不是因为我没有Python标头,而是因为我以某种方式将它们从自制python目录中删除了.在Freenode的Python频道上聊天后,一位用户帮助我确定了问题.

So it turns out I was wrong about the cause of the problem. It was not because I didn't have the Python headers, it was because I had somehow deleted them all from the homebrew python directory. After some chatting on Freenode's Python channel, a user helped me identify the problem. There were only three files in

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

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

所以我跑了

brew uninstall python
brew install python

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

which reinstalled the headers and fixed the problem!

这篇关于找不到在Mac OS X上安装python-dev的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆