在os X 10.7 Lion上设置Django的最佳方法是什么?

时间:2012-02-22 21:37:19

标签: python django osx-lion clang

我在原始安装和Xcode 4.3上在os X 10.7上设置Python和Django。

我尝试使用Python的默认安装:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/

我通常使用名为easy_install的基于Python的包管理器。 Easy_install似乎无法找到编译器。

编辑:当我尝试安装MySQL-python时出现了这个错误:

$ sudo easy_install MySQL-python 
Password:
Searching for MySQL-python
Reading http://pypi.python.org/simple/MySQL-python/
Reading http://sourceforge.net/projects/mysql-python/
Reading http://sourceforge.net/projects/mysql-python
Best match: MySQL-python 1.2.3
Downloading http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz
Processing MySQL-python-1.2.3.tar.gz
Running MySQL-python-1.2.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-P9H9WX/MySQL-python-1.2.3/egg-dist-tmp-rRTfZL
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
unable to execute llvm-gcc-4.2: No such file or directory
error: Setup script exited with error: command 'llvm-gcc-4.2' failed with exit status 1

错误:安装脚本退出并显示错误:命令'llvm-gcc-4.2'因退出状态1而失败 显然,系统尝试使用用于编译已安装的Python框架的相同编译器。 出于某种原因,Apple没有包含llvm-gcc-4.2。

Xcode 4.1使用了GCC,但Xcode 4.3似乎已经改变了 从我可以收集到的,Apple希望使用Clang作为编译器与GCC。 所以我加入了.bash_profile:

CC =铛

我决定用clang重新编译Python,但首先,我需要安装readline 失败:

Wed Feb 22 16:04:59 ~/Downloads/readline-6.2 
$ ./configure
checking build system type... i386-apple-darwin11.3.0
checking host system type... i386-apple-darwin11.3.0

Beginning configuration for readline-6.2 for i386-apple-darwin11.3.0

checking whether make sets $(MAKE)... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/Bryan/Downloads/readline-6.2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

在Lion 10.7上安装Django的最简单方法是什么?

4 个答案:

答案 0 :(得分:13)

您是否使用Xcode 4.3安装了命令行工具?默认情况下不安装它们。您可以通过转到Xcode 4.3首选项中的“下载”窗格来安装它们。

答案 1 :(得分:0)

尝试更新XCode并重新安装所有全局网站包。您可能还想尝试使用pip而不是easy_install。

您也可以尝试使用

进行编译
export ARCHFLAGS='-arch i386 -arch x86_64'

在升级OSX版本时,这解决了我过去的许多问题。

答案 2 :(得分:0)

太强硬了方式

首先,确保安装Xcode(在Mac App Store中免费提供)。它包括编译某些Python包可能需要的所有构建工具。

要获得easy_install,只需下载setuptools并按照说明在该链接上安装Mac OS X.

完成后,您可以easy_install virtualenv获得一个很好的隔离环境。

答案 3 :(得分:0)

对于MySQL问题,您必须编辑site.cfg文件:

mysql_config = /usr/local/mysql/bin/mysql_config

然后:

$ python setup.py build
$ sudo python setup.py install
相关问题