27

我需要 uWSGI 来运行 django 项目。因此,当我尝试安装 uWSGI 时,它给了我一个错误消息“例外:您需要 C 编译器来构建 uWSGI”。但是mac自带gcc编译器。

我已经从“ http://projects.unbit.it/uwsgi/wiki/WikiStart#Getit ”下载了 uWSGI,并尝试通过命令“python setup.py install”进行安装

这是我在安装 uWSGI 时遇到的错误

running install
using profile: buildconf/default.ini
detected include path: ['/usr/local/include', '/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple
darwin11/4.2.1/include', '/usr/include', '/System/Library/Frameworks', '/Library/Frameworks']
Traceback (most recent call last):
  File "setup.py", line 98, in <module>
    distclass=uWSGIDistribution,
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py",
line 152, in setup
    dist.run_commands()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py",
line 953, in run_commands
    self.run_command(cmd)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py",
line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 61, in run
    conf = uc.uConf(get_profile())
  File "/Users/jay/Downloads/Softwares/Work/uwsgi-1.2.4/uwsgiconfig.py", line 340, in __init__
    raise Exception("you need a C compiler to build uWSGI")
Exception: you need a C compiler to build uWSGI
4

5 回答 5

39

gcc already installed, just export CC=gcc will be ok.

于 2012-08-04T17:30:58.400 回答
18

distutils 可能返回类似“gcc-4.2”而不是普通的旧“gcc”。

使用 sudo 等,您可能想要执行以下操作:

sudo CC=gcc pip install uwsgi
于 2013-02-18T21:09:29.270 回答
6

安装命令行工具

$xcode-select --install

然后运行

$pip install uwsgi
于 2017-03-16T14:14:47.087 回答
0

在您的 Mac 中安装 Xcode,而不是在 Xcode 首选项中选择命令行工具。它通过 pip install uwsgi 为我工作

于 2020-08-06T14:23:45.657 回答
0

首先安装 gcc 编译器

xcode-select --install
于 2020-01-16T11:06:09.397 回答