Linux安装fbprophet的一些错误和解决办法

首先按照官网安装,可以看到需要安装pystan,在对应的页面告诉我们pystan安装需要anaconda,还是先去装anaconda把,安装方法就是去官网下载sh文件,执行bash指令就行,之后pip安装gcc,pystan等,但是用pip安装fbprophet的时候报错

[root@ml-cent-2 site-packages]# pip install fbprophet
Collecting fbprophet
  Downloading https://files.pythonhosted.org/packages/83/a1/a39be1675a62597e4c0d4fdaeb65b14752b8aa8afc92e90edd91614353ab/fbprophet-0.3.post2.tar.gz
Requirement already satisfied: Cython>=0.22 in /root/anaconda3/lib/python3.6/site-packages (from fbprophet) (0.28.2)
Requirement already satisfied: pystan>=2.14 in /root/anaconda3/lib/python3.6/site-packages (from fbprophet) (2.17.1.0)
Requirement already satisfied: numpy>=1.10.0 in /root/anaconda3/lib/python3.6/site-packages (from fbprophet) (1.14.3)
Requirement already satisfied: pandas>=0.20.1 in /root/anaconda3/lib/python3.6/site-packages (from fbprophet) (0.23.0)
Requirement already satisfied: matplotlib>=2.0.0 in /root/anaconda3/lib/python3.6/site-packages (from fbprophet) (2.2.2)
Requirement already satisfied: python-dateutil>=2.5.0 in /root/anaconda3/lib/python3.6/site-packages (from pandas>=0.20.1->fbprophet) (2.7.3)
Requirement already satisfied: pytz>=2011k in /root/anaconda3/lib/python3.6/site-packages (from pandas>=0.20.1->fbprophet) (2018.4)
Requirement already satisfied: cycler>=0.10 in /root/anaconda3/lib/python3.6/site-packages (from matplotlib>=2.0.0->fbprophet) (0.10.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /root/anaconda3/lib/python3.6/site-packages (from matplotlib>=2.0.0->fbprophet) (2.2.0)
Requirement already satisfied: six>=1.10 in /root/anaconda3/lib/python3.6/site-packages (from matplotlib>=2.0.0->fbprophet) (1.11.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /root/anaconda3/lib/python3.6/site-packages (from matplotlib>=2.0.0->fbprophet) (1.0.1)
Requirement already satisfied: setuptools in /root/anaconda3/lib/python3.6/site-packages (from kiwisolver>=1.0.1->matplotlib>=2.0.0->fbprophet) (39.1.0)
Building wheels for collected packages: fbprophet
  Running setup.py bdist_wheel for fbprophet ... error
  Complete output from command /root/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-1g925uox/fbprophet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-hjvqj981 --python-tag cp36:
  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
  
  ----------------------------------------
  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
    Complete output from command /root/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-1g925uox/fbprophet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-42uk60yu/install-record.txt --single-version-externally-managed --compile:
    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
    
    ----------------------------------------
Command "/root/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-1g925uox/fbprophet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-42uk60yu/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-1g925uox/fbprophet/

去外国网站查,有人说用

conda install -c conda-forge fbprophet
conda install gcc

但是我conda的proxy设置有些问题,就没试过

最后找到了解决办法,少安装了gcc-c++的依赖库

So the issue is with pystan and in particular something in the C++ compiler. Could you try making sure that these packages are installed in Fedora:

@centos

sudo yum install gcc gcc-c++

@Ubuntu

sudo apt-get install build-essential

之后使用

pip install fbprophet

或者直接下载github上的源代码,进入python目录使用

python3 setup.py install

都可以安装成功

但是用pip安装的在之后使用发现会出现缺少库

>>> import matplotlib
>>> import fbprophet
ERROR:fbprophet.plot:Importing matplotlib failed. Plotting will not work.

还以为没安装,实际上是安装了但是和fbprophet不在相同路径中

[root@cent-3 spark-2.3.1-bin-hadoop2.7]# pip install matplotlib
Requirement already satisfied: matplotlib in /root/anaconda3/lib/python3.6/site-packages (2.2.2)

因为实际查看后发现路径是包含matplotlib安装位置的

>>> import sys
>>> print(sys.path)
['', ...,'/root/anaconda3/lib/python3.6/site-packages']

用pip卸载fbprophet后用github的代码装,还是会出现同样错误

官方github讨论区查看

In v0.3 you can now load prophet without matplotlib installed and it will just print a warning (not fail with ImportError). It is still listed as a install dependency in PyPI, but you can get around that by installing from source (python setup.py install) and removing matplotlib from the requirements.txt. I think that should satisfy most of the need for this, but we can reopen if there is more to be done here. @bletham

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值