兼容性强的
fbprophet
安装环境及依赖包选择1. 创建虚拟环境
建议使用 Anaconda 创建一个新的虚拟环境,以避免依赖冲突:
conda create -n fbprophet_env python=3.8
conda activate fbprophet_env
2. 安装依赖包
在安装
fbprophet
之前,需要安装以下依赖包:conda install libpython m2w64-toolchain -c msys2
conda install numpy pandas matplotlib scipy
-
numpy
和pandas
是数据处理的基础库。 -
matplotlib
用于绘图。 -
scipy
提供科学计算功能。 -
pystan
是fbprophet
的核心依赖之一。
之后单独安装
conda install pystan -c conda-forge
3. 安装 fbprophet
在虚拟环境中安装
fbprophet
:
conda install -c conda-forge fbprophet
4. 处理可能出现的错误
-
holidays
报错:如果遇到holidays
相关的错误,可以尝试安装特定版本的holidays
:bash复制 conda install holidays==0.17.2
-
pandas
版本问题:如果遇到pandas
版本问题,可以尝试降级pandas
到 1.3.5:pip uninstall pandas
pip install pandas==1.3.5conda install numpy==1.19.5此外还可能需要安装以下模块pip install setuptools-git>=1.2
pip install cmdstanpy==0.9.5
pip install holidays==0.17.2
pip install plotlyconda install xlrd
pip install baostock
pip install pdfplumber
pip install fsspec
如果要求spyder中调试,还可安装:conda install spyder
5. 验证安装
在 Python 环境中运行以下代码,验证
fbprophet
是否成功安装:
from fbprophet import Prophet
print("fbprophet 已成功安装!")
注意事项
-
环境隔离:始终在虚拟环境中安装和运行
fbprophet
,以避免影响全局环境。 -
依赖冲突:如果在安装过程中遇到依赖冲突,建议尝试升级或降级相关依赖包,或者重新创建虚拟环境。
-
Python 版本:确保使用的是 Python 3.8,因为
fbprophet
可能不支持更高版本的 Python。
通过上述步骤,你应该能够在 Python 3.8 环境下成功安装并使用
fbprophet
。如果仍有问题,请提供更多上下文信息,以便进一步协助你解决。最终安装好后,各模块的版本如下:
pip list
Package Version
----------------------------- -----------
aiohappyeyeballs 2.4.0
aiohttp 3.10.5
aiosignal 1.2.0
alabaster 0.7.12
arrow 1.3.0
arviz 0.15.1
astroid 3.2.4
asttokens 2.0.5
async-timeout 4.0.3
asyncssh 2.17.0
atomicwrites 1.4.0
attrs 24.2.0
autopep8 2.0.4
Babel 2.11.0
backcall 0.2.0
baostock 0.8.9
beautifulsoup4 4.12.3
binaryornot 0.4.4
black 24.8.0
bleach 4.1.0
Bottleneck 1.3.5
Brotli 1.0.9
certifi 2024.8.30
cffi 1.17.1
cftime 1.6.2
chardet 4.0.0
charset-normalizer 3.3.2
click 8.1.7
cloudpickle 3.0.0
cmdstanpy 0.9.5
colorama 0.4.6
comm 0.2.1
contourpy 1.0.5
convertdate 2.4.0
cookiecutter 2.6.0
cryptography 43.0.0
cycler 0.11.0
Cython 3.0.11
debugpy 1.6.7
decorator 5.1.1
defusedxml 0.7.1
Deprecated 1.2.13
diff-match-patch 20200713
dill 0.3.8
docstring-to-markdown 0.11
docutils 0.18.1
ephem 4.1.5
executing 0.8.3
fastjsonschema 2.16.2
fbprophet 0.7.1
flake8 7.1.1
fonttools 4.51.0
frozenlist 1.4.0
fsspec 2025.2.0
h5netcdf 1.1.0
h5py 3.11.0
hijri-converter 2.3.1
holidays 0.17.2
idna 3.7
imagesize 1.4.1
importlib-metadata 7.0.1
importlib_resources 6.4.0
inflection 0.5.1
intervaltree 3.1.0
ipykernel 6.29.5
ipython 8.12.2
isort 5.13.2
jaraco.classes 3.2.1
jedi 0.19.1
jellyfish 1.0.1
Jinja2 3.1.4
jsonschema 4.23.0
jsonschema-specifications 2023.7.1
jupyter_client 8.6.0
jupyter_core 5.7.2
jupyterlab-pygments 0.2.2
keyring 24.3.1
kiwisolver 1.4.4
korean-lunar-calendar 0.3.1
LunarCalendar 0.0.9
markdown-it-py 2.2.0
MarkupSafe 2.1.3
matplotlib 3.6.2
matplotlib-inline 0.1.6
mccabe 0.7.0
mdurl 0.1.0
mistune 2.0.4
mkl-fft 1.3.8
mkl-random 1.2.4
mkl-service 2.4.0
more-itertools 10.3.0
multidict 6.0.4
mypy-extensions 1.0.0
narwhals 1.25.2
nbclient 0.8.0
nbconvert 7.16.4
nbformat 5.10.4
nest-asyncio 1.6.0
netCDF4 1.6.2
numexpr 2.8.4
numpy 1.19.5
numpydoc 1.5.0
packaging 24.1
pandas 1.3.5
pandocfilters 1.5.0
parso 0.8.3
pathspec 0.10.3
pdfminer.six 20231228
pdfplumber 0.11.5
pexpect 4.8.0
pickleshare 0.7.5
pillow 10.4.0
pip 24.2
pkgutil_resolve_name 1.3.10
platformdirs 3.10.0
plotly 6.0.0
pluggy 1.0.0
ply 3.11
pooch 1.7.0
prompt-toolkit 3.0.43
psutil 5.9.0
ptyprocess 0.7.0
pure-eval 0.2.2
pycodestyle 2.12.1
pycparser 2.21
pydocstyle 6.3.0
pyflakes 3.2.0
PyGithub 2.4.0
Pygments 2.15.1
PyJWT 2.8.0
pylint 3.2.7
pylint-venv 3.0.3
pyls-spyder 0.4.0
PyMeeus 0.5.12
PyNaCl 1.5.0
pyparsing 3.0.9
pypdfium2 4.30.1
PyQt5 5.15.10
PyQt5-sip 12.13.0
PyQtWebEngine 5.15.6
PySocks 1.7.1
pystan 2.19.1.1
python-dateutil 2.9.0.post0
python-lsp-black 2.0.0
python-lsp-jsonrpc 1.1.2
python-lsp-server 1.12.0
python-slugify 5.0.2
pytoolconfig 1.2.6
pytz 2024.1
pyuca 1.2
pywin32 305.1
pywin32-ctypes 0.2.2
PyYAML 6.0.2
pyzmq 25.1.2
QDarkStyle 3.2.3
qstylizer 0.2.2
QtAwesome 1.3.1
qtconsole 5.6.0
QtPy 2.4.1
referencing 0.30.2
requests 2.32.3
rich 13.7.1
rope 1.12.0
rpds-py 0.10.6
Rtree 1.0.1
scipy 1.10.1
setuptools 75.1.0
setuptools-git 1.2
sip 6.7.12
six 1.16.0
snowballstemmer 2.2.0
sortedcontainers 2.4.0
soupsieve 2.5
Sphinx 5.0.2
sphinxcontrib-applehelp 1.0.2
sphinxcontrib-devhelp 1.0.2
sphinxcontrib-htmlhelp 2.0.0
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.3
sphinxcontrib-serializinghtml 1.1.5
spyder 6.0.1
spyder-kernels 3.0.0
stack-data 0.2.0
superqt 0.6.7
text-unidecode 1.3
textdistance 4.2.1
three-merge 0.1.1
tinycss2 1.2.1
tomli 2.0.1
tomlkit 0.13.2
tornado 6.4.1
tqdm 4.67.1
traitlets 5.14.3
typing_extensions 4.12.2
tzdata 2023.3
ujson 5.10.0
unicodedata2 15.1.0
Unidecode 1.3.8
urllib3 2.2.3
watchdog 4.0.1
wcwidth 0.2.5
webencodings 0.5.1
whatthepatch 1.0.2
wheel 0.44.0
win-inet-pton 1.1.0
wrapt 1.14.1
xarray 2023.1.0
xarray-einstats 0.5.1
xlrd 2.0.1
yapf 0.40.2
yarl 1.11.0
zipp 3.20.2
Package Version
----------------------------- -----------
aiohappyeyeballs 2.4.0
aiohttp 3.10.5
aiosignal 1.2.0
alabaster 0.7.12
arrow 1.3.0
arviz 0.15.1
astroid 3.2.4
asttokens 2.0.5
async-timeout 4.0.3
asyncssh 2.17.0
atomicwrites 1.4.0
attrs 24.2.0
autopep8 2.0.4
Babel 2.11.0
backcall 0.2.0
baostock 0.8.9
beautifulsoup4 4.12.3
binaryornot 0.4.4
black 24.8.0
bleach 4.1.0
Bottleneck 1.3.5
Brotli 1.0.9
certifi 2024.8.30
cffi 1.17.1
cftime 1.6.2
chardet 4.0.0
charset-normalizer 3.3.2
click 8.1.7
cloudpickle 3.0.0
cmdstanpy 0.9.5
colorama 0.4.6
comm 0.2.1
contourpy 1.0.5
convertdate 2.4.0
cookiecutter 2.6.0
cryptography 43.0.0
cycler 0.11.0
Cython 3.0.11
debugpy 1.6.7
decorator 5.1.1
defusedxml 0.7.1
Deprecated 1.2.13
diff-match-patch 20200713
dill 0.3.8
docstring-to-markdown 0.11
docutils 0.18.1
ephem 4.1.5
executing 0.8.3
fastjsonschema 2.16.2
fbprophet 0.7.1
flake8 7.1.1
fonttools 4.51.0
frozenlist 1.4.0
fsspec 2025.2.0
h5netcdf 1.1.0
h5py 3.11.0
hijri-converter 2.3.1
holidays 0.17.2
idna 3.7
imagesize 1.4.1
importlib-metadata 7.0.1
importlib_resources 6.4.0
inflection 0.5.1
intervaltree 3.1.0
ipykernel 6.29.5
ipython 8.12.2
isort 5.13.2
jaraco.classes 3.2.1
jedi 0.19.1
jellyfish 1.0.1
Jinja2 3.1.4
jsonschema 4.23.0
jsonschema-specifications 2023.7.1
jupyter_client 8.6.0
jupyter_core 5.7.2
jupyterlab-pygments 0.2.2
keyring 24.3.1
kiwisolver 1.4.4
korean-lunar-calendar 0.3.1
LunarCalendar 0.0.9
markdown-it-py 2.2.0
MarkupSafe 2.1.3
matplotlib 3.6.2
matplotlib-inline 0.1.6
mccabe 0.7.0
mdurl 0.1.0
mistune 2.0.4
mkl-fft 1.3.8
mkl-random 1.2.4
mkl-service 2.4.0
more-itertools 10.3.0
multidict 6.0.4
mypy-extensions 1.0.0
narwhals 1.25.2
nbclient 0.8.0
nbconvert 7.16.4
nbformat 5.10.4
nest-asyncio 1.6.0
netCDF4 1.6.2
numexpr 2.8.4
numpy 1.19.5
numpydoc 1.5.0
packaging 24.1
pandas 1.3.5
pandocfilters 1.5.0
parso 0.8.3
pathspec 0.10.3
pdfminer.six 20231228
pdfplumber 0.11.5
pexpect 4.8.0
pickleshare 0.7.5
pillow 10.4.0
pip 24.2
pkgutil_resolve_name 1.3.10
platformdirs 3.10.0
plotly 6.0.0
pluggy 1.0.0
ply 3.11
pooch 1.7.0
prompt-toolkit 3.0.43
psutil 5.9.0
ptyprocess 0.7.0
pure-eval 0.2.2
pycodestyle 2.12.1
pycparser 2.21
pydocstyle 6.3.0
pyflakes 3.2.0
PyGithub 2.4.0
Pygments 2.15.1
PyJWT 2.8.0
pylint 3.2.7
pylint-venv 3.0.3
pyls-spyder 0.4.0
PyMeeus 0.5.12
PyNaCl 1.5.0
pyparsing 3.0.9
pypdfium2 4.30.1
PyQt5 5.15.10
PyQt5-sip 12.13.0
PyQtWebEngine 5.15.6
PySocks 1.7.1
pystan 2.19.1.1
python-dateutil 2.9.0.post0
python-lsp-black 2.0.0
python-lsp-jsonrpc 1.1.2
python-lsp-server 1.12.0
python-slugify 5.0.2
pytoolconfig 1.2.6
pytz 2024.1
pyuca 1.2
pywin32 305.1
pywin32-ctypes 0.2.2
PyYAML 6.0.2
pyzmq 25.1.2
QDarkStyle 3.2.3
qstylizer 0.2.2
QtAwesome 1.3.1
qtconsole 5.6.0
QtPy 2.4.1
referencing 0.30.2
requests 2.32.3
rich 13.7.1
rope 1.12.0
rpds-py 0.10.6
Rtree 1.0.1
scipy 1.10.1
setuptools 75.1.0
setuptools-git 1.2
sip 6.7.12
six 1.16.0
snowballstemmer 2.2.0
sortedcontainers 2.4.0
soupsieve 2.5
Sphinx 5.0.2
sphinxcontrib-applehelp 1.0.2
sphinxcontrib-devhelp 1.0.2
sphinxcontrib-htmlhelp 2.0.0
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.3
sphinxcontrib-serializinghtml 1.1.5
spyder 6.0.1
spyder-kernels 3.0.0
stack-data 0.2.0
superqt 0.6.7
text-unidecode 1.3
textdistance 4.2.1
three-merge 0.1.1
tinycss2 1.2.1
tomli 2.0.1
tomlkit 0.13.2
tornado 6.4.1
tqdm 4.67.1
traitlets 5.14.3
typing_extensions 4.12.2
tzdata 2023.3
ujson 5.10.0
unicodedata2 15.1.0
Unidecode 1.3.8
urllib3 2.2.3
watchdog 4.0.1
wcwidth 0.2.5
webencodings 0.5.1
whatthepatch 1.0.2
wheel 0.44.0
win-inet-pton 1.1.0
wrapt 1.14.1
xarray 2023.1.0
xarray-einstats 0.5.1
xlrd 2.0.1
yapf 0.40.2
yarl 1.11.0
zipp 3.20.2
若按此方法安装后依然报错:
File ~\anaconda3\envs\p38\lib\site-packages\spyder_kernels\customize\utils.py:209 in exec_encapsulate_locals
exec_fun(compile(code_ast, filename, "exec"), globals)
File d:\projects\stock\src\tools\modeltest.py:11
from fbprophet import Prophet
File ~\anaconda3\envs\p38\lib\site-packages\fbprophet\__init__.py:8
from fbprophet.forecaster import Prophet
File ~\anaconda3\envs\p38\lib\site-packages\fbprophet\forecaster.py:17
from fbprophet.make_holidays import get_holiday_names, make_holidays_df
File ~\anaconda3\envs\p38\lib\site-packages\fbprophet\make_holidays.py:14
import fbprophet.hdays as hdays_part2
File ~\anaconda3\envs\p38\lib\site-packages\fbprophet\hdays.py:17
from holidays import WEEKEND, HolidayBase, Turkey
File ~\anaconda3\envs\p38\lib\site-packages\holidays\__init__.py:17
from holidays.constants import *
File ~\anaconda3\envs\p38\lib\site-packages\holidays\constants.py:15
from holidays.calendars.gregorian import (
File ~\anaconda3\envs\p38\lib\site-packages\holidays\calendars\__init__.py:15
from holidays.calendars.buddhist import _BuddhistLunisolar, _CustomBuddhistHolidays
File ~\anaconda3\envs\p38\lib\site-packages\holidays\calendars\buddhist.py:23
class _BuddhistLunisolar:
File ~\anaconda3\envs\p38\lib\site-packages\holidays\calendars\buddhist.py:428 in _BuddhistLunisolar
def _get_holiday(self, holiday: str, year: int) -> tuple[Optional[date], bool]:
TypeError: 'type' object is not subscriptable
exec_fun(compile(code_ast, filename, "exec"), globals)
File d:\projects\stock\src\tools\modeltest.py:11
from fbprophet import Prophet
File ~\anaconda3\envs\p38\lib\site-packages\fbprophet\__init__.py:8
from fbprophet.forecaster import Prophet
File ~\anaconda3\envs\p38\lib\site-packages\fbprophet\forecaster.py:17
from fbprophet.make_holidays import get_holiday_names, make_holidays_df
File ~\anaconda3\envs\p38\lib\site-packages\fbprophet\make_holidays.py:14
import fbprophet.hdays as hdays_part2
File ~\anaconda3\envs\p38\lib\site-packages\fbprophet\hdays.py:17
from holidays import WEEKEND, HolidayBase, Turkey
File ~\anaconda3\envs\p38\lib\site-packages\holidays\__init__.py:17
from holidays.constants import *
File ~\anaconda3\envs\p38\lib\site-packages\holidays\constants.py:15
from holidays.calendars.gregorian import (
File ~\anaconda3\envs\p38\lib\site-packages\holidays\calendars\__init__.py:15
from holidays.calendars.buddhist import _BuddhistLunisolar, _CustomBuddhistHolidays
File ~\anaconda3\envs\p38\lib\site-packages\holidays\calendars\buddhist.py:23
class _BuddhistLunisolar:
File ~\anaconda3\envs\p38\lib\site-packages\holidays\calendars\buddhist.py:428 in _BuddhistLunisolar
def _get_holiday(self, holiday: str, year: int) -> tuple[Optional[date], bool]:
TypeError: 'type' object is not subscriptable
则检查系统中是否多安装了以下模块:
bcrypt 3.2.0
cached-property 1.5.2
lazy-object-proxy 1.10.0
paramiko 2.8.1
cached-property 1.5.2
lazy-object-proxy 1.10.0
paramiko 2.8.1
若存在,则删除以上模块。
著作权归作者所有。商业转载请联系本站作者获得授权,非商业转载请注明出处 ZZKOOK。
评论
喜欢这的氛围。
知识共享,善莫大焉