I'd like to install fbprophet in a Docker container. My Dockerfile looks like this:
FROM python:3.7
RUN pip install --upgrade pip
RUN pip install fbprophet
Building the image errors on the "pip install fbprophet" step with this stack trace:
Running setup.py install for fbprophet ... error
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7ei5jssc/fbprophet_9a3a667ec353402389a02258feccfe51/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7ei5jssc/fbprophet_9a3a667ec353402389a02258feccfe51/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-741oj2zp/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7m/fbprophet
cwd: /tmp/pip-install-7ei5jssc/fbprophet_9a3a667ec353402389a02258feccfe51/
Complete output (10 lines):
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/fbprophet
creating build/lib/fbprophet/stan_model
Importing plotly failed. Interactive plots will not work.
INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_dfdaf2b8ece8a02eb11f050ec701c0ec NOW.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7ei5jssc/fbprophet_9a3a667ec353402389a02258feccfe51/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7ei5jssc/fbprophet_9a3a667ec353402389a02258feccfe51/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-741oj2zp/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7m/fbprophet Check the logs for full command output.
There are a number of suggestions I've found online that I've tried unsuccessfully
(at this point I built the container without fbprophet and ran it, so I could try commands live):
- Here the problem was that gcc/g++ weren't installed.
- I tried
apt install g++ gcc, still fails to build (they were already installed)
- pnmartinez's comment here suggests some missing build tools.
- I did
apt-get install build-essential libncursesw5-dev libreadline-gplv2-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev libffi-dev zlib1g-dev(after runningapt-get upgrade,apt-get update,apt-get dist-upgrade), and retried with same result.
- This GH issue suggests downgrading to
pystan==2.18.
- Before this commit
introduced in v0.6, Prophet restricted itself to PyStan <=2.18.1, so I tried pip install prophet==0.5, which still failed. (I went all the way down to 0.2, still failed.) I then tried
pip3 uninstall pystan && pip3 install pystan==2.18 && pip3 install fbprophet==0.5with the same result.
- Install from conda-forge instead
- I looked into this, but installing a working conda env in a docker container seems pretty complicated
- I also started trying to install on an Alpine-based container instead of Debian.
- I started running into issues there before the Prophet stage, and in general I would assume building a complicated C++ project won't be easier on a non-standard distro.
It appears that the problem occurs when gcc tries to build a PyStan model. My guess is that it is simply running out of memory (the cc1plus proc on top uses 2GB, about 90% of RAM, someone claims here it can use up to 8GB). However, this is pretty common software, and I succeeded in installing fbprophet with the same Dockerfile a few months back, so I'm not sure why this has become a problem. (I've tried building it both on macOS (Big Sur) and Linux (Fedora 33) with the same result.)