Installation


Python


Greykite is currently available in Python, and has been tested on the following versions on Linux, MacOS, and Windows:

  • Python 3.10.2
  • Greykite is available on PyPI, so you can install via

    $ pip install greykite

    or

    $ python -m pip install greykite.

    Note: starting from version 0.2.0, prophet and its dependencies were converted to optional dependencies. They are not installed with greykite. To use the related functionalities, you will need to install them manually. To install prophet, you can do

    $ pip install prophet==1.0.1

    Greykite was tested compatible with prophet 1.0.1, however we have stopped providing support for newer versions.

    We recommend setting up python virtual environment with the proper python version (e.g. 3.10.2) to install greykite.

    To install in a virtual environment, the steps typically look like this:

    Linux

    In your directory of interest, with the python version you want to use,

    $ python -m venv greykite-env
      $ source greykite-env/bin/activate
      $ pip install greykite
    MacOS

    Install xcode if you don’t already have it:

    $ xcode-select --install.

    Install openblas if you don’t already have it:

    $ brew install openblas.

    In your directory of interest, with the python version you want to use,

    $ python -m venv greykite-env
      $ source greykite-env/bin/activate
      $ OPENBLAS="$(brew --prefix openblas)" pip install greykite

    If you encounter issues with any dependency, install the version required by greykite using pip. For example:

    $ pip install numpy==1.22.0.

    Then try installing greykite again:

    $ OPENBLAS="$(brew --prefix openblas)" pip install greykite.
    Windows

    We highly recommend using miniconda for installation, to use m2w64-toolchain for GCC. Anaconda also works, but it comes with extra packages that may need to be reinstalled with the proper version anyway.

    In general, Greykite works under Python 3.10 on windows. If you think you will need prophet, we recommend Python 3.7 on Windows to avoid potential issues.

    $ conda create --name greykite-venv python=3.7
      $ conda activate greykite-venv
      $ conda install -c msys2 libpython m2w64-toolchain
      $ conda install pip
      $ pip install greykite

    If you encounter issues with any dependency, install the version required by greykite using conda. For example:

    $ conda install -c conda-forge numpy=1.22.0.

    Then try installing greykite again:

    $ pip install greykite.

    Check installation


    To test installation, first check if the greykite package is available:

    $ pip show greykite.

    Then run a quickstart or tutorial example from our docs to create a forecast and get familiar with the library.

    You may open a jupyter notebook to run code as follows:

    $ jupyter notebook.

    To render plots in the notebook, use notebook mode and replace `plotly.io.show` with `iplot`:

    >>> from plotly.offline import init_notebook_mode, iplot
      >>> init_notebook_mode(connected=True)  # for plots to render in jupyter notebook
      >>> # ... notebook code ...
      >>> # plotly.io.show(fig)  # replace these with `iplot`
      >>> iplot(fig)

    FAQs


    All platforms
    1. During installation, I see the following error and warning:

      ERROR: Failed building wheel for pystan
        DEPRECATION: pystan was installed using the legacy 'setup.py install' method, because a wheel could not be built for it.

      This is just a warning. The package was successfully installed using a legacy install method. You may see this for some packages, such as pystan, fbprophet or pyzmq.

      1. Check if installation succeeded: $ pip show greykite.
      2. If not, install the package first using pip or conda, then try installing greykite again.

      Update: if you are installing greykite >=0.2.0, fbprophet and pystan are optional dependencies. This issue will only potentially appear when you install fbprophet manually.

    2. After installation, when I try to open jupyter notebook, it takes forever to connect to kernel.

      This is likely because tornado was not properly installed. In this case, you need to

      1. uninstall tornado: $ pip uninstall tornado.
      2. install tornado 6.*: $ pip install tornado==6.2.
    Linux
    1. After installation, I see the following error during imports:

      Traceback (most recent call last):
        File "/home/kayang/test_pypi/env377/lib/python3.10/site-packages/pandas/io/common.py", line 3, in <module>
        import bz2
        File "/usr/local/lib/python3.10/bz2.py", line 19, in <module>
        from _bz2 import BZ2Compressor, BZ2Decompressor
        ModuleNotFoundError: No module named '_bz2'

      This is probably because you build python from source, and you haven't installed the bz2 library when building python. In this case, you need to

      1. install the bz2 library
        1. Ubuntu/Debian: $ sudo apt-get install libbz2-dev
        2. Fedora/CentOS/RedHat: $ sudo yum install bzip2-devel
      2. reinstall python and greykite.
    2. After installation, I see the following error when trying to open jupyter notebook:

      ModuleNotFoundError: No module named '_sqlite3'
        ModuleNotFoundError: No module named 'pysqlite2'

      This is probably because you build python from source, and you haven't installed the sqlite library when building python. In this case, you need to

      1. install the sqlite library
        1. Ubuntu/Debian: $ sudo apt-get install libsqlite-dev
        2. Fedora/CentOS/RedHat: $ sudo yum install sqlite-devel
      2. reinstall python and greykite.
    MacOS
    1. During installation, I see the following error:

      RuntimeError: Found /usr/lib/libcblas.dylib, but that file is a symbolic link to the MacOS Accelerate framework,
        which is not supported by NumPy. You must configure the build to use a different optimized library, or disable
        the use of optimized BLAS and LAPACK by setting the environment variables NPY_BLAS_ORDER="" and NPY_LAPACK_ORDER=""
        before building NumPy.
      or
      numpy.distutils.system_info.NotFoundError: No BLAS/LAPACK libraries found. Note: Accelerate is no longer supported.
        To build Scipy from sources, BLAS & LAPACK libraries need to be installed.

      This is because Numpy no longer supports MacOS accelerated framework. In this case, you need to

      1. install the openblas library: $ brew install openblas.
      2. reinstall greykite with the brew-installed openblas: $ OPENBLAS="$(brew --prefix openblas)" pip install greykite.
    2. During installation, I see the following error:

      ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly
        WARNING: You are using pip version 19.2.3, however version 21.1 is available.
        You should consider upgrading via the 'pip install --upgrade pip' command.

      In this case, you need to

      1. upgrade pip: $ pip install --upgrade pip.
      2. reinstall greykite: $ OPENBLAS="$(brew --prefix openblas)" pip install greykite.
    3. After installation, during imports, I see the following error with matplotlib:

      E   ImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly
       if Python is not installed as a framework. See the Python documentation for more information on installing Python as
       a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are
       using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib
       on OSX' in the Matplotlib FAQ for more information.

      This is because python is not properly installed as a framework. In this case, you can reinstall python properly, or you can switch the backend.

      1. create the profile $ vim ~/.matplotlib/matplotlibrc.
      2. specify the backend TkAgg by adding the following to the profile: backend: TkAgg.
    4. After installation, during imports, I see the following error with matplotlib:

      E   ModuleNotFoundError: No module named '_tkinter'

      This is because python is not properly installed as a framework. In this case, you can reinstall python properly, or you can switch the backend.

      1. create the profile $ vim ~/.matplotlib/matplotlibrc.
      2. specify the backend Agg by adding the following to the profile: backend: agg.