Mac Sierra安装Nupic报错的解决方法

Nupic是Numenta组织的一款开源的Python AI框架,它基于HTM(Hierarchical Temporal Memory)理论构建,它的特点是实时处理数据流,经过HTM模型对数据进行预测;主要用于异常检测和数据预测,在学习Nupic之前首要任务是安装它,但在Mac系统下使用pip install nupic会报如下错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  /private/var/folders/54/pctkjyhx27z54q0zmn6y_qy80000gp/T/pip-build-XrwvaS/pycapnp/build/include/kj/common.h:78:10: fatal error: 'initializer_list' file not found
#include <initializer_list>
^~~~~~~~~~~~~~~~~~
2 warnings and 1 error generated.
error: command 'gcc' failed with exit status 1

----------------------------------------
Failed building wheel for pycapnp
Running setup.py clean for pycapnp
Running setup.py bdist_wheel for PyYAML ... done
Stored in directory: /Users/Webb/Library/Caches/pip/wheels/01/6b/98/ec896c71d1d4e39330931d229e6323b9f459ae6593c4ae9dda
Running setup.py bdist_wheel for validictory ... done
Stored in directory: /Users/Webb/Library/Caches/pip/wheels/b4/6c/cd/2e3ed38ab5eea23d9cba0c94d1217739ef87a2d4e922b38125
Running setup.py bdist_wheel for prettytable ... done
Stored in directory: /Users/Webb/Library/Caches/pip/wheels/ba/73/dd/7a489b5a7be36959e02a168d7f387e96eae676ddb96838bda3
Successfully built asteval unittest2 pytest-xdist pyproj ordereddict psutil DBUtils coverage python-dateutil mock PyYAML validictory prettytable
Failed to build pycapnp
Installing collected packages: asteval, unittest2, apipkg, execnet, py, pytest, pytest-xdist, pyproj, PyMySQL, ordereddict, psutil, DBUtils, coverage, pycapnp, pytest-cov, numpy, nupic.bindings, six, python-dateutil, mock, PyYAML, validictory, prettytable, nupic
Running setup.py install for pycapnp ... error
Complete output from command /Users/Webb/Conda/envs/numenta/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/54/pctkjyhx27z54q0zmn6y_qy80000gp/T/pip-build-XrwvaS/pycapnp/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/54/pctkjyhx27z54q0zmn6y_qy80000gp/T/pip-W_i7x9-record/install-record.txt --single-version-externally-managed --compile:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/54/pctkjyhx27z54q0zmn6y_qy80000gp/T/pip-build-XrwvaS/pycapnp/setup.py", line 92, in <module>
from Cython.Distutils import build_ext as build_ext_c
ImportError: No module named Cython.Distutils

----------------------------------------
Command "/Users/Webb/Conda/envs/numenta/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/54/pctkjyhx27z54q0zmn6y_qy80000gp/T/pip-build-XrwvaS/pycapnp/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/54/pctkjyhx27z54q0zmn6y_qy80000gp/T/pip-W_i7x9-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/54/pctkjyhx27z54q0zmn6y_qy80000gp/T/pip-build-XrwvaS/pycapnp/

解决办法:

由于错误提示Failed to build pycapnp
在终端输入以下命令即可解决:

1
2
3
(numenta) Webb@MacBookPro ~$ brew uninstall capnp
(numenta) Webb@MacBookPro ~$ export MACOSX_DEPLOYMENT_TARGET=10.10
(numenta) Webb@MacBookPro ~$ CFLAGS='-stdlib=libc++' pip install nupic