- 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 - Environment Setup
The environment setup is the first step before installing Prophet. We need to create a space in our system where all necessary dependencies can work together. Prophet is most commonly used with the Python programming language, and it is recommended to create a virtual environment for it.
A virtual environment is a separate space within the system that contains its own python interpreter and libraries. It allows Prophet and its required packages to be installed without affecting other python projects or the main system setup.
Python Version Requirements
Prophet requires Python 3.7 or higher. To check which version of python we have installed, we can use the following command in our terminal or command prompt.
python --version
If you're using an older version, you will need to upgrade. It's recommended to use Python 3.8 or 3.9, as these versions offer better compatibility with Prophet and its dependencies.
Core Dependencies
The most important libraries that Prophet depends on are −
- NumPy − for numerical operations.
- Pandas − for data manipulation and handling time series data.
- Matplotlib − for plotting and visualizing results.
- PyStan (or CmdStanPy) − for performing the statistical modeling through Bayesian inference.
PyStan uses a C++ compiler, so it's important to have the right one installed for the operating system. Without it, the installation can run into errors.
Choosing the Development Environment
When working with Prophet, the choice of development environment depends on the project and personal preference.
- Jupyter Notebook − This is great for data science work. Code can be run in small parts and results appear immediately. Useful for experimenting, creating charts, and learning Prophet.
- Python scripts in an IDE (PyCharm, VS Code, Spyder) − This is best for standard software development or production projects. Provide debugging, version control, and project management features.
- Google Colab − This is good for beginners. It provides a free cloud-based Jupyter Notebook, so no local setup is needed. Prophet can be installed and used in each session.
Using Virtual Environments
It is highly recommended to use virtual environments when working with Prophet. To create a new virtual environment run the following code.
python -m venv myenv
Once the environment is created, activate it based on operating systems.
On Windows −
myenv\Scripts\activate
On macOS/Linux −
source myenv/bin/activate
Choosing a Package Manager
Use either pip or conda, the two main Python package managers to install Prophet. pip is Python's default package manager. To install Prophet with pip, run the following code in the terminal or command prompt.
pip install Prophet
Conda is a package manager included with the Anaconda distribution. It handles both Python and non-Python dependencies, which makes installations easier. To install Prophet with conda, run the following code.
conda install -c conda-forge Prophet
System-Specific Setup
The setup process depends on the operating system −
- On Windows, install Microsoft Visual C++ Build Tools because Prophet has dependencies like pystan that require C++ compilation.
- On macOS, install Xcode Command Line Tools.
- On Linux, most compilers are already available, but on Ubuntu/Debian, install build-essential to ensure gcc and g++ are ready. After the system setup, create and activate a virtual environment before installing Prophet.
Memory and Performance Considerations
A minimum of 4GB RAM is needed, and 8GB or more is recommended for larger datasets or complex models. CPU usage can be high because Prophet uses MCMC sampling, and it will use multiple cores if available to speed up computations.
Pre-Installation Environment Checks
Before installing Prophet, the system can be verified for all necessary requirements −
Python Version −
python --version
Core Dependencies −
python -c "import numpy; print(numpy.__version__)" python -c "import pandas; print(pandas.__version__)" python -c "import matplotlib; print(matplotlib.__version__)" python -c "import pystan; print(pystan.__version__)" # or cmdstanpy
Virtual Environment −
python -m venv test_env # Activate: # Windows test_env\Scripts\activate # macOS/Linux source test_env/bin/activate
Package Manager Check −
pip --version # or conda --version
Version Management
Check Prophet version by running the below code −
pip show Prophet
Environment Portability
Use virtual environments and generate a requirements.txt to replicate the setup.
pip freeze > requirements.txt
Docker can be used for full portability across machines.
Conclusion
This chapter covered the environment setup for Prophet, including checking the Python version, verifying dependencies, and creating a virtual environment to prevent installation errors.
In the next chapter, the installation of Prophet will be shown, along with a test on a basic time series dataset to confirm that the environment is ready for forecasting.