ImportError: cannot import name 'NDArray' from 'numpy.typing' (Prophet)

Question:

I have not had as much trouble trying to install any other package in my Python experience than I have with Prophet.

Here is a snippet of my code:

#Import libraries
import pandas as pd
from prophet import Prophet

#Load data
test = pd.read_csv('https://raw.githubusercontent.com/facebook/prophet/main/examples/example_wp_log_peyton_manning.csv')
test.head()

# Train model
model = prophet()
model.fit(test)

I get the following error:

----> 4 from prophet import Prophet
      7 # Train model
      8 model = prophet()

File ~/anaconda3/envs/prophet39/lib/python3.9/site-packages/prophet/__init__.py:7
      1 # Copyright (c) 2017-present, Facebook, Inc.
      2 # All rights reserved.
      3 #
      4 # This source code is licensed under the BSD-style license found in the
      5 # LICENSE file in the root directory of this source tree. An additional grant
      6 # of patent rights can be found in the PATENTS file in the same directory.
----> 7 from prophet.forecaster import Prophet
      9 from pathlib import Path
     10 about = {}

File ~/anaconda3/envs/prophet39/lib/python3.9/site-packages/prophet/forecaster.py:17
     15 import numpy as np
     16 import pandas as pd
---> 17 from numpy.typing import NDArray
     19 from prophet.make_holidays import get_holiday_names, make_holidays_df
     20 from prophet.models import StanBackendEnum

ImportError: cannot import name 'NDArray' from 'numpy.typing' (/Users/user_name/anaconda3/envs/prophet39/lib/python3.9/site-packages/numpy/typing/__init__.py)

I have no idea how to fix this problem. I’ve encountered several different prophet/pystan issues along the way, but seems like I’ve hit quite the roadblock this time.

Asked By: user2813606

||

Answers:

Try upgrading your numpy and prophet installations. It seems that updating has resolved a similar issue in the past.

Answered By: L0tad