4

I have a python project which relies on pystan (for fbprophet). As part of a CI/CD workflow I am trying to set up jenkins to build the images and push to a docker registry. However, the pip installation of pystan is super slow. Seems to be stuck at this stage for 10+ minutes:

Building wheels for collected packages: pystan, pymeeus
  Building wheel for pystan (setup.py): started
  Building wheel for pystan (setup.py): still running ...

Jenkins appears to become unresponsive on a t2.medium anytime I try to build the image.

Is there another way to install pystan? Download the wheels beforehand? How can I figure out what is making it so slow?

I could potentially start form a base docker image which already has pystan installed perhaps?

erncyp
  • 1,649
  • 21
  • 23

2 Answers2

9

PyStan currently provides a number of precompiled wheels for different platforms and Python versions except for Python 3.8.

Can I guess you use Python 3.8? Try downgrading to 3.7 — pip should install PyStan without compilation.

phd
  • 82,685
  • 13
  • 120
  • 165
  • 1
    As you and @kichik guessed I was using 3.8. Downgrading to 3.7 solved the issue! – erncyp Feb 28 '20 at 16:24
  • literally hanging in my 16 core laptop; but installed in a snap in python 3.7 docker image; If someone wants the docker image with pytstan 2.19.1.1 and facebook prophet 'docker pull alexcpn/fb_prophet_python:3.7.13-buster' – Alex Punnen Mar 21 '22 at 13:36
6

pip decided not to use one of the prebuilt wheels and so it has to build the package from source. pystan seems to be a big package with a lot of C++ code, so it can take a while to build. This is especially true on a weak machine like t2.medium that has very limited I/O.

You can tell pip to only use binary packages (wheel) and also print some more details. That might tell you why it didn't use a wheel in the first place.

pip install -v --only-binary pystan pystan pymeeus

A common reason for not using wheels is a mismatch in the Python version. This package only has wheels for 2.7, 3.5, 3.6 and 3.7. Maybe you're using Python 3.8. Another common reason is mismatch in platform. This package has manylinux1_x86_64 but you might be using i686 or a distro that's somehow incompatible with manylinux1.

kichik
  • 33,220
  • 7
  • 94
  • 114