代码语言:javascript复制
Collecting fbprophet
Using cached https://files.pythonhosted.org/packages/33/fb/ad98d46773929079657706e6b2b6e366ba6c282bc2397d8f9b0ea8e5614c/fbprophet-0.5.tar.gz
Requirement already satisfied: Cython>=0.22 in /usr/local/lib/python3.6/site-packages (from fbprophet) (0.29.2)
Requirement already satisfied: pystan>=2.14 in /usr/local/lib/python3.6/site-packages (from fbprophet) (2.19.0.0)
Requirement already satisfied: numpy>=1.10.0 in /usr/local/lib/python3.6/site-packages (from fbprophet) (1.15.4)
Requirement already satisfied: pandas>=0.23.4 in /usr/local/lib/python3.6/site-packages (from fbprophet) (0.24.2)
Requirement already satisfied: matplotlib>=2.0.0 in /usr/local/lib/python3.6/site-packages (from fbprophet) (2.1.1)
Requirement already satisfied: lunardate>=0.1.5 in /usr/local/lib/python3.6/site-packages (from fbprophet) (0.2.0)
Requirement already satisfied: convertdate>=2.1.2 in /usr/local/lib/python3.6/site-packages (from fbprophet) (2.1.3)
Requirement already satisfied: holidays>=0.9.5 in /usr/local/lib/python3.6/site-packages (from fbprophet) (0.9.10)
Requirement already satisfied: setuptools-git>=1.2 in /usr/local/lib/python3.6/site-packages (from fbprophet) (1.2)
Requirement already satisfied: pytz>=2011k in /usr/local/lib/python3.6/site-packages (from pandas>=0.23.4->fbprophet) (2017.3)
Requirement already satisfied: python-dateutil>=2.5.0 in /usr/local/lib/python3.6/site-packages (from pandas>=0.23.4->fbprophet) (2.6.1)
Requirement already satisfied: six>=1.10 in /usr/local/lib/python3.6/site-packages (from matplotlib>=2.0.0->fbprophet) (1.11.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/site-packages (from matplotlib>=2.0.0->fbprophet) (2.2.0)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/site-packages (from matplotlib>=2.0.0->fbprophet) (0.10.0)
Requirement already satisfied: ephem<3.8,>=3.7.5.3 in /usr/local/lib/python3.6/site-packages (from convertdate>=2.1.2->fbprophet) (3.7.6.0)
Building wheels for collected packages: fbprophet
Building wheel for fbprophet (setup.py) ... error
ERROR: Complete output from command /usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-1d7ho9yv/fbprophet/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-c4yb__rd --python-tag cp36:
ERROR: running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/fbprophet
creating build/lib/fbprophet/stan_model
INFO:pystan:COMPILING THE C CODE FOR MODEL anon_model_861b75c6337e237650a61ae58c4385ef NOW.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for fbprophet
Running setup.py clean for fbprophet
Failed to build fbprophet
Installing collected packages: fbprophet
Running setup.py install for fbprophet ... error
ERROR: Complete output from command /usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-1d7ho9yv/fbprophet/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-n386ioss/install-record.txt --single-version-externally-managed --compile:
ERROR: running install
running build
running build_py
creating build
creating build/lib
creating build/lib/fbprophet
creating build/lib/fbprophet/stan_model
INFO:pystan:COMPILING THE C CODE FOR MODEL anon_model_861b75c6337e237650a61ae58c4385ef NOW.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command "/usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-1d7ho9yv/fbprophet/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-n386ioss/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-1d7ho9yv/fbprophet/
centos环境下
error: command 'gcc' failed with exit status 1
这个问题是因为fbprophet安装是依赖pystan ,而pystan 需要C 编译器
fbprophet建议使用Anaconda安装,不容易出问题
当前error: command 'gcc' failed with exit status 1 问题一般有几种:
1、pystan 版本,使用2.17.1.0 版本,本人测过没问题
sudo pip uninstall pystan sudo pip install pystan==2.17.1.0 sudo pip install fbprophet
2、安装gcc相关
yum install gcc gcc-c
yum groupinstall "Development Tools" 相当于 build-essential
3、python dev相关
yum install python-devel
添加源:yum install -y https://centos7.iuscommunity.org/ius-release.rpm
通过搜索找到对应的dev包:yum search python36u-deve
4、虚拟机内存
如果使用的是虚拟机,请注意安装FBProphet至少需要4GB内存,使用FBProphet至少需要2GB内存。
测试pystan 方法
创建py文件test.py:
代码语言:javascript复制import pystan
model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
model = pystan.StanModel(model_code=model_code) # this will take a minute
y = model.sampling(n_jobs=1).extract()['y']
y.mean() # should be close to 0
执行python test.py