- Prophet - Home
- Prophet - Introduction
- Prophet - Basics of Time Series
- Prophet - Environment Setup
- Prophet - Installation
- Prophet - Installation in R
- Prophet - Getting Started
- Prophet Fundamentals
- Prophet - Data Preparation
- Prophet Useful Resources
- Prophet - Useful Resources
- Prophet - Discussion
Python Prophet - Installation
Prophet can be installed using Conda, Pip, Google Colab, or directly from source. Below are the instructions for each method along with tips for verifying the installation and troubleshooting common issues.
Installing with Conda
Open your terminal or Anaconda Prompt and run the following command −
conda install -c conda-forge prophet
Conda will fetch the package, solve dependencies, and install Prophet. You'll see messages showing the download and installation progress as shown below.
Collecting package metadata (current repodata json): done
Solving environment: done
Package Plan
environment location: /Users/username/anaconda3/envs/myenv
added or updated specs:
- prophet
The following packages will be downloaded:
package | build
-----------------|-----------------
prophet 1.1.5 | py39h6e9494a_0 123 KB conda forge
pystan 2.19.1.1 | py39h329af84_2 12.3 MB conda forge
...
Proceed (y or n)?
Once you type y and press Enter, Conda will start downloading and installing Prophet along with its dependencies.
You'll see messages confirming progress like this.
Downloading and Extracting Packages prophet 1.1.5 | 123 KB | ############################### | 100% pystan 2.19.1.1 | 12.3 MB | ############################### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done
When you see "done" at the end, that means the installation completed successfully.
To install a specific version, run the following command.
conda install -c conda forge prophet=1.1.1
Troubleshooting Conda Installation
If Conda fails to solve the environment, try updating Conda first by running the following command −
conda update conda
If you still encounter conflicts or dependency issues, consider creating a fresh environment using the commands below −
conda create -n myenv python=3.9 conda activate myenv conda install -c conda-forge prophet
Note that the Conda environment should be using Python 3.7 or higher, as Prophet does not support earlier versions.
Installing With Pip
Open your terminal or command prompt and run the following command.
pip install prophet
you'll see output below showing Pip downloading, building, and installing Prophet and its dependencies.
Collecting prophet
Downloading prophet-1.1.5.tar.gz (72 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 72.4/72.4 kB 2.1 MB/s eta 0:00:00
Collecting pystan>=2.14 (from prophet)
Downloading pystan-2.19.1.1.tar.gz (15.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.8/15.8 MB 8.2 MB/s eta 0:00:00
Building wheels for collected packages: prophet, pystan
Building wheel for prophet (setup.py) ... done
Building wheel for pystan (setup.py) ... done
Successfully built prophet pystan
Installing collected packages: pystan, prophet
Successfully installed prophet-1.1.5 pystan-2.19.1.1
The compilation process may show additional compiler messages. This is normal and takes several minutes.
After installation, check that Prophet is installed correctly by running the following commands.
import prophet print(prophet.__version__)
To install a specific version run the below code.
pip install prophet==1.1.1
Troubleshooting Pip Installation
On Windows − If installation fails due to compiler errors, try installing wheel first −
pip install wheel
On Mac/Linux − Make sure you have a C++ compiler installed (like gcc) since PyStan requires it. On macOS, you can install developer tools using the following command.
xcode-select --install
Virtual Environments − It's recommended to install Prophet in a virtual environment to avoid conflicts with other packages.
python -m venv myenv source myenv/bin/activate # On Windows use `myenv\Scripts\activate` pip install prophet
Installing Prophet in Google Colab
If you're using Google Colab, installing Prophet is direct since Colab comes with Python and pip pre-installed.
In a notebook cell, run the following command −
!pip install prophet
You'll see the installation progress and messages in the notebook, like downloading packages and building wheels, shown below −
Collecting prophet Downloading prophet-1.1.5.tar.gz (72 kB) Collecting pystan>=2.14 (from prophet) Downloading pystan-2.19.1.1.tar.gz (15.8 MB) Building wheels for collected packages: prophet, pystan Building wheel for prophet (setup.py) ... done Building wheel for pystan (setup.py) ... done Successfully built prophet pystan Installing collected packages: pystan, prophet Successfully installed prophet-1.1.5 pystan-2.19.1.1
After installation, check that Prophet is working.
import prophet print(prophet.__version__)
Always run the installation cell at the start of a session, restart the runtime if Prophet doesn't import correctly, and optionally install a specific version by running the following command.
!pip install prophet==1.1.1.
Troubleshooting Google Colab Installation
If Prophet doesn't install or import correctly in Google Colab, restart the runtime and run the installation command again −
!pip install prophet
Sometimes Colab uses an older cached version of PyStan or dependencies. To avoid this, upgrade cmdstanpy and reinstall Prophet −
!pip install --upgrade cmdstanpy prophet
If the error still appears, try clearing the environment by running the following commands.
!pip uninstall prophet -y !pip install prophet
Verifying the Installation
After installing Prophet, it's important to confirm that everything is working properly. Open Python, a Jupyter notebook, or a Google Colab notebook and run the following command to import Prophet −
from prophet import Prophet
If no errors appear, this means Prophet has been imported successfully. To check which version of Prophet is installed, run the following commands.
import prophet print(prophet.__version__)
The output should display its version which is similar to 1.1.5.
Functionality Test
We will just test whether everything is working fine or not with this small example. First, we import the required libraries by running the following command.
from prophet import Prophet import pandas as pd
Then, we create a sample dataset with 100 consecutive dates starting from January 1, 2020, and numeric values.
# Create some sample data
df = pd.DataFrame({
'ds': pd.date_range(start='2020-01-01', periods=100),
'y': range(100)
})
Below is the output of the above program.
ds y 0 2020-01-01 0 1 2020-01-02 1 2 2020-01-03 2 3 2020-01-04 3 4 2020-01-05 4
Next, we initialize a Prophet model and fit it to the dataset.
# Fit the Prophet model model = Prophet() model.fit(df)
Finally, we print a confirmation message to verify that Prophet is working correctly.
print("Prophet is working correctly!")
After running it, we get output as shown below.
INFO:prophet:Disabling yearly seasonality. Run prophet with yearly_seasonality=True to override this. INFO:prophet:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this. Prophet is working correctly!
Installing from Source (Advanced)
If you want to install the latest development version of Prophet directly from GitHub, run the following command in your terminal or command prompt.
pip install git+https://github.com/facebook/prophet.git
Conclusion
In this chapter, we've covered various ways to install Prophet, including using Conda, Pip, Google Colab, and installing directly from source. We also discussed troubleshooting tips to help resolve common installation issues. In the next chapter, we will look at how to install Prophet using R.