prophet: Pip install error ModuleNotFoundError: No module named 'pystan'
pip --version
pip 9.0.1 from /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (python 3.6)
pip install fbprophet
Collecting fbprophet
Downloading fbprophet-0.2.1.tar.gz
Requirement already satisfied: matplotlib in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from fbprophet)
Requirement already satisfied: pandas>=0.18.1 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from fbprophet)
Collecting pystan>=2.14 (from fbprophet)
Downloading pystan-2.17.0.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (35.2MB)
100% |████████████████████████████████| 35.2MB 43kB/s
Requirement already satisfied: python-dateutil>=2.0 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from matplotlib->fbprophet)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from matplotlib->fbprophet)
Requirement already satisfied: cycler>=0.10 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from matplotlib->fbprophet)
Requirement already satisfied: numpy>=1.7.1 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from matplotlib->fbprophet)
Requirement already satisfied: six>=1.10 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from matplotlib->fbprophet)
Requirement already satisfied: pytz in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from matplotlib->fbprophet)
Collecting Cython!=0.25.1,>=0.22 (from pystan>=2.14->fbprophet)
Downloading Cython-0.27.3-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.7MB)
100% |████████████████████████████████| 4.7MB 290kB/s
Building wheels for collected packages: fbprophet
Running setup.py bdist_wheel for fbprophet ... error
Complete output from command /Users/miasool/pyenvs/xor_ai/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/c0/mz0pnjn131d5rsl43kr5my6xh2lw2t/T/pip-build-19fj5puw/fbprophet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/c0/mz0pnjn131d5rsl43kr5my6xh2lw2t/T/tmpe7pukz0npip-wheel- --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/fbprophet
creating build/lib/fbprophet/stan_models
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/c0/mz0pnjn131d5rsl43kr5my6xh2lw2t/T/pip-build-19fj5puw/fbprophet/setup.py", line 126, in <module>
"""
File "/Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 204, in run
self.run_command('build')
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/private/var/folders/c0/mz0pnjn131d5rsl43kr5my6xh2lw2t/T/pip-build-19fj5puw/fbprophet/setup.py", line 46, in run
build_stan_models(target_dir)
File "/private/var/folders/c0/mz0pnjn131d5rsl43kr5my6xh2lw2t/T/pip-build-19fj5puw/fbprophet/setup.py", line 28, in build_stan_models
from pystan import StanModel
ModuleNotFoundError: No module named 'pystan'
----------------------------------------
Failed building wheel for fbprophet
Running setup.py clean for fbprophet
Failed to build fbprophet
Installing collected packages: Cython, pystan, fbprophet
Running setup.py install for fbprophet ... done
Successfully installed Cython-0.27.3 fbprophet-0.2.1 pystan-2.17.0.0
However with the second run it showed no error
pip install fbprophet
Requirement already satisfied: fbprophet in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages
Requirement already satisfied: matplotlib in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from fbprophet)
Requirement already satisfied: pandas>=0.18.1 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from fbprophet)
Requirement already satisfied: pystan>=2.14 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from fbprophet)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from matplotlib->fbprophet)
Requirement already satisfied: numpy>=1.7.1 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from matplotlib->fbprophet)
Requirement already satisfied: six>=1.10 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from matplotlib->fbprophet)
Requirement already satisfied: cycler>=0.10 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from matplotlib->fbprophet)
Requirement already satisfied: pytz in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from matplotlib->fbprophet)
Requirement already satisfied: python-dateutil>=2.0 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from matplotlib->fbprophet)
Requirement already satisfied: Cython!=0.25.1,>=0.22 in /Users/miasool/pyenvs/xor_ai/lib/python3.6/site-packages (from pystan>=2.14->fbprophet)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 32
- Comments: 44 (12 by maintainers)
Commits related to this issue
- Clearer pip install snippet This simple change may prevent further additions to and discussions in #401 and #1598 and the like. — committed to earthgecko/prophet by earthgecko 4 years ago
- Clearer pip install snippet (#1629) * Clearer pip install snippet This simple change may prevent further additions to and discussions in #401 and #1598 and the like. * Clearer pip install snipp... — committed to facebook/prophet by earthgecko 4 years ago
- Fixed dependency error for pystan. Refer https://github.com/facebook/prophet/issues/401 — committed to gyani91/darts by gyani91 3 years ago
- docs: examples: or covid data by county: Fix for https://github.com/facebook/prophet/issues/401#issuecomment-865193633 Signed-off-by: John Andersen <johnandersenpdx@gmail.com> — committed to pdxjohnny/dffml by pdxjohnny 3 years ago
- docs: examples: or covid data by county: Fix for https://github.com/facebook/prophet/issues/401#issuecomment-865193633 Signed-off-by: John Andersen <johnandersenpdx@gmail.com> — committed to intel/dffml by pdxjohnny 3 years ago
- docs: examples: or covid data by county: Fix for https://github.com/facebook/prophet/issues/401#issuecomment-865193633 Signed-off-by: John Andersen <johnandersenpdx@gmail.com> — committed to pdxjohnny/dffml by pdxjohnny 3 years ago
- docs: examples: or covid data by county: Fix for https://github.com/facebook/prophet/issues/401#issuecomment-865193633 Signed-off-by: John Andersen <johnandersenpdx@gmail.com> — committed to intel/dffml by pdxjohnny 3 years ago
I had this issue with Python 3.9, miniconda debian docker image
If you are currently having issues with importing pystan in fbprophet, this is most likely caused by pystan 3.0.
See here:
I recommend to downgrade pystan to
2.19.1.1- latest pre-3 version. I recommend to downgrade to python 3.8 (repositories contain pre-compiled binaries, but not for 3.9)Installation worked for me to install pystan using conda, and fbprophet using pip
If you would like to use 3.9 - check that g++, gcc is installed.
According to the installation page of FbProphet:
Install pystan with pip before using pip to install prophet
pystan>=3.0 is currently not supported
$ pip install pystan==2.19.1.1 $ $ pip install prophet
nice work for a two year issue and it’s unimaginable to keep this issue going for two years.
OK,maybe it’s necessary to install pystan manually .but why write
pystan>=2.14at setup.py? Also, when we usepip install fbprophetthere is also many error such asModuleNotFoundError: No module named 'convertdate'causeFailed building wheel for fbprophet.It always cause building fail . If Exception is expected,you should not usebuild_models(target_dir)at setup.py @blethamAs @z4yed said, this works for me.
$ python3 -m pip install “pystan==2.19.1.1”
You saved my day! Thank you.
It seems this error only occurs when package wheel is already installed. If wheel is not installed, setup.py bdist_wheel will not be invoked. If wheel is installed, wheel building fails because it happens before pystan has been installed. Perhaps pystan should be listed in both install_requires and setup_requires?
Struggled with this issue too today while installing fbprophet on Ubuntu 16.04.
Only thing that helped me to solve this issue: upgrade pip to version 10 and later
After that
pip install fbprophetstarted to work as intended.I just went through the same problem and resolved it using this issues (which was replied by a meta employee):
pip install pystan==2.19.1.1(you have to specify some old version otherwise it will install the latest version, which is titledstanrather thanpystanand installingfbprophetwill prompt ModuleNotFound “pystan” error.pip install fbprophetWe reverted the addition of the pyproject.toml file in https://github.com/facebook/prophet/commit/34af9efb89dd22df8237a1e9363f67521e932100. Here’s the deal:
fbprophet requires pystan to build.
pip installwill by default do the install in this order: (1) build a wheel for fbprophet, (2) install package dependencies, (3) install fbprophet from the wheel.If pystan is not already installed, this is a problem: Pystan is needed to build the wheel in (1), but is not installed until (2). Thus building the wheel fails with the error at the start of this issue.
The issue is not super serious, because when the wheel fails to build, step (3) is replaced with installing the package from source, which then succeeds because it happens after pystan is installed in (2). But having an error message during install is obviously not ideal and can be confusing to users. Note also that if pystan is already installed, the wheel will successfully build.
Hence we tried to solve the problem in the recommended way, which is to specify build dependencies in a pyproject.toml file. This changes the
pip installflow first step to be (1) Set up a build environment, install all of the packages from pyproject.toml in that environment, and build the wheel in that environment. The install then proceeds to steps 2 and 3 as above, outside of the build environment.This solves the problem because pytsan is installed in the build environment prior to building the wheel.
However, it introduces another significant issue: The build environment is no longer the same as the run environment. Pystan is installed from scratch in the build environment, and is not necessarily the same version or configured in the same way as in the run environment, which is really problematic because Pystan can require some special configuration to get it to build correctly. We ran into a specific issue with this in OSX where building the wheel would fail in the build environment, but work fine outside the build environment. The issue is that Pystan is not hooked up correctly to the C++ compiler in the build environment - we haven’t figured out why yet, but if we ran into this issue on one of our machines certainly other users will too.
Another issue is that the build environment does not necessarily have the same version of Pystan as the system. For instance, I have Pystan 2.18.0 installed in my system python, but the build environment pulled the latest version of Pystan (2.18.1) and built the wheel using that. This can be a serious issue for users that already have pystan installed and are upgrading fbprophet, because changes in Stan can make it so that models compiled under one version of Pystan cannot be loaded in another. For instance, if I have Pystan 2.14 installed, the models will be compiled under Pystan 2.18.1, but my local 2.14 will not be upgraded. When I try to load the models in my 2.14, it will fail.
We need to be sure that the Pystan used in the build environment is the same version and hooked up the same way as in the system py, and so have removed pyproject.toml until we figure out how that can be done.
In the meantime: If you get this error, you can ignore it. If you don’t want to avoid it, just install pystan before installing fbprophet.
just change version of pystan and install this power full library i think suitable version of pystan is —> 2.19.1.1 just run this command = (pip install pystan==2.19.1.1) have a nice day all
By the way, if you’re trying to do this in a Docker image or a requirements.txt file, you can just list it twice, e.g.
As of May 15, 2023, this approach does not work.
@shraddhajadhav7 , Prophet 1.1 has been released and has simplified the install workflow and removed the Pystan requirement
You can now
pip install prophetto install a pre-compiled wheelSo, adding pystan to setup_requires does indeed make sure that it is in place before trying to build fbprophet, and thus avoids this confusing error message.
However, it seems (TIL) that pip does not directly interact with setup_requires. Rather, during the build it uses easy_install to install everything from setup_requires. easy_install does not support wheels, and so it means that pystan has to be built from source. This takes forever and uses a ton of RAM. It is thus not a good option here.
I think the best fix we can get for this is just to update the install instructions to say to install pystan with pip before installing fbprophet with pip.