Quickly Setting up Prophet with Python 3.x in Windows 10

Hamdan Mohammed Ridwan
3 min readMay 7, 2020

--

Prophet is an open-source tool developed by researchers at Facebook that can be used for forecasting data points that strongly exhibit multiple seasonalities. The Python implementation is provided as package called fbprophet, which can be a little tricky to set up just Python in Windows due to the difficulty in installing Pystan, a package which it depends on heavily. Quite a few people tend to face difficulties with the installations of either fbprophet or PyStan at multiple stages, as evident from many unresolved

If you use Python by itself (as opposed to using it with a distribution platform such as Anaconda), installation of PyStan with pip is often unsuccessful as it does not support Microsoft Visual Studio C++ compiler. Hence, it requires installing and configuring another compatible compiler, which PyStan developers themselves acknowledge to be a challenging step. For this reason, using an Anaconda distribution is preferable, as it makes installing C++ compiler a breeze.

Below, I describe the steps to set up fbprophet, which can be followed in case you face difficulties despite following the installation instructions in the official documentation. This can be especially useful if you have a messy environment with multiple installations of Python or if different versions of the same packages are installed across multiple virtual environments and the root environment.

Disclaimer: Obviously, there are multiple ways to set this up. I went through the process of installing and uninstalling a few times and I am listing down what worked in my case.

Scenario 1: Python or Anaconda were never installed on your system

This is a pretty straightforward scenario except that creating a conda virtual environment may later cause conflicts or inconsistencies and lead to problems later on.

  1. Install Anaconda and make sure you add its location to the path environment variable on you system.
  2. Follow the instructions here to the dot to install PyStan, skipping the section “Create a conda virtual environment (optional)”.
  3. Once PyStan is successfuly installed, run the following command in conda either in the console in Spyder or in the Anaconda Command Prompt, in the root environemt itself:

conda install -c conda-forge fbprophet

This should complete the installation. Sometimes, you may also have to install Plotly manually, which you can do with the following command:

conda install -c plotly plotly

Scenario 2: Python and Anaconda were installed separately, and now exist alongside each other

If you had Python 3.x installed before you installed Anaconda, the chances are that the reason for at least some of the errors is the presence of multiple versions of Python on your system.

  1. Uninstall Python completely. From Start Menu>Settings>Apps, uninstall Python as well Python Launcher which still remains after you uninstall Python. Uninstalling Python Launcher seemed to resolve one of the errors that I faced, for reasons I am not sure of.
  2. Delete the Python location from the path environement variable, and make sure Anaconda’s location is included in it.
  3. Follow steps 2 and 3 in Scenario 1 above.
  4. If you still encounter any errors, in terms of a conflicts between packages, it could be that the there are multiple conda virtual environments on your system. The easiest solution is to then uninstall Anaconda, after which you can follow the steps in Scenario 1 above.

--

--