Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3.7.0: Something went wrong while unpickling the StanModel. Consider recompiling. #775

Closed
shil3754 opened this issue Dec 19, 2018 · 33 comments

Comments

@shil3754
Copy link

shil3754 commented Dec 19, 2018

OS: Windows 7 Professional

First of all, I have read through related threads #249 #252 and #599, but still cannot figure out how to solve this issue.

I understand that the easiest way to install fbprophet is to run
conda install -c conda-forge fbprophet
but for reasons I don't know, it takes forever for conda to solve the environment. It's not the case if I use conda to install other packages.
So instead I used pip and it reported that fbprophet 0.4 was installed successfully. But I then got the following error message when importing fbprophet
WARNING:pystan:No module named 'stanfit4anon_model_861b75c6337e237650a61ae58c4385ef_2841341000846931969'
WARNING:pystan:Something went wrong while unpickling the StanModel. Consider recompiling.

Before installing fbprophet, I followed this instruction to install pystan and checked that pystan is working properly. By running the following code.
import pystan
model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
model = pystan.StanModel(model_code=model_code) # this will take a minute
y = model.sampling(n_jobs=1).extract()['y']
y.mean() # should be close to 0

I got message like

Gradient evaluation took 0 seconds
1000 transitions using 10 leapfrog steps per transition would take 0 seconds.
Adjust your expectations accordingly!

Iteration: 1 / 2000 [ 0%] (Warmup)
Iteration: 200 / 2000 [ 10%] (Warmup)
Iteration: 400 / 2000 [ 20%] (Warmup)
Iteration: 600 / 2000 [ 30%] (Warmup)
Iteration: 800 / 2000 [ 40%] (Warmup)
Iteration: 1000 / 2000 [ 50%] (Warmup)
Iteration: 1001 / 2000 [ 50%] (Sampling)
Iteration: 1200 / 2000 [ 60%] (Sampling)
Iteration: 1400 / 2000 [ 70%] (Sampling)
Iteration: 1600 / 2000 [ 80%] (Sampling)
Iteration: 1800 / 2000 [ 90%] (Sampling)
Iteration: 2000 / 2000 [100%] (Sampling)

Elapsed Time: 0.01 seconds (Warm-up)
0.01 seconds (Sampling)
0.02 seconds (Total)

I uninstalled both pystan and fbprophet and then reinstalled them with --no-cache flag. But fbprophet still didn't work.

@dghete
Copy link

dghete commented Dec 19, 2018

I'm getting exactly the same error on OSX with fbpropeht 0.4 and pystan 2.18.0.0
Also tried re-installing with no-chache but it did not helped as reported in other tickets.

@jiapei100
Copy link

Same problem here, but with Python 3.6.7

@shil3754
Copy link
Author

I solved this issue by uninstalling anaconda 5.3.1 completely and installing anaconda 5.2.0, which comes with python 3.6.5. Then conda works wonders to install fbprophet.

I suspect that this is a python version issue, especially after I checked several mirrors, for example, only to see that there are no fbprophet versions matching pythoh 3.7. I guess that is why it takes forever for conda to solve the environment when python version is 3.7.0.
I tried to downgrade python 3.7 to python 3.6 by running
conda install python=3.6
but it failed because of too many dependencies. Therefore I choose to reinstall the whole anaconda.

@Gordonei
Copy link
Contributor

Gordonei commented Dec 20, 2018

Similar to @jiapei100 , I'm seeing this same issue with python 3.6.7, although I'm using Ubuntu 18.04 and pip to install.

I think this might be an issue with prophet 0.4, which strangely enough is listed on pypi, but not in Github as a release. It was also released yesterday.

Force downgrading to the version before seems to have before fixed things for me: pip3 install --upgrade --force-reinstall --no-cache fbprophet==0.3.post2.

I wonder if building from source might also fix things - the error message seems to suggest some prebuilt STAN model is broken.

@dghete
Copy link

dghete commented Dec 20, 2018

Forcing fbprophet to 0.3.post2 worked for me as a fix.

@mydpy
Copy link

mydpy commented Dec 20, 2018

Also failed for prophet 0.4.0, Python 3.5.2, and pystan 2.18.0.0. Rolling back to 0.3.post2 fixed the issue.

@bletham
Copy link
Contributor

bletham commented Dec 20, 2018

This can happen when there is a change in the model (with a new version of fbprophet, or a new version of PyStan) and pip is still using a wheel that is compiled with the old version. We just pushed a new version of fbprophet to PyPI. This should fix the issue (without having to downgrade):

pip3 uninstall fbprophet
pip3 install fbprophet --no-cache-dir --no-binary :all:

@ciphor
Copy link

ciphor commented Dec 20, 2018

It is still not working for me.
Python 3.6.5, pystan 2.18.0.0, fbprophet 0.4
When trying to import fbprophet,

WARNING:pystan:No module named 'stanfit4anon_model_861b75c6337e237650a61ae58c4385ef_2841341000846931969'
WARNING:pystan:Something went wrong while unpickling the StanModel. Consider recompiling.

@vavlopes
Copy link

vavlopes commented Dec 21, 2018

Facing the same problem that @ciphor related. Could someone reopen the issue ?

Using on databricks:

WARNING:pystan:No module named 'stanfit4anon_model_861b75c6337e237650a61ae58c4385ef_2841341000846931969'
WARNING:pystan:Something went wrong while unpickling the StanModel. Consider recompiling.

@shil3754 shil3754 reopened this Dec 24, 2018
@shil3754
Copy link
Author

repoen the issue on the request of @vavlopes

@billhumanlytics
Copy link

Facing the same issue too, python 3.6, pystan and numpy newest version. Using docker for deployment. Do not see the error when doing on my local env, but when it is deployed using python 3.6 docker it returns the error and all modeling fails.

@luckykris
Copy link

i face to the same problem , and i try to figure out why the WARNING come out ,then i found pystan generate wrong StanfitModel like this:
stanfit4anon_model_861b75c6337e237650a61ae58c4385ef_2841341000846931969.cpython-36m-darwin.so
but my platform is
image
the reason why the model generate by pystan can not be import is pystan complie wrong .so file

@luckykris
Copy link

i face to the same problem , and i try to figure out why the WARNING come out ,then i found pystan generate wrong StanfitModel like this:
stanfit4anon_model_861b75c6337e237650a61ae58c4385ef_2841341000846931969.cpython-36m-darwin.so
but my platform is
image
the reason why the model generate by pystan can not be import is pystan complie wrong .so file

i re-install 0.3post2, this problem is solved ,pystan complie the right .so like this
stanfit4anon_model_861b75c6337e237650a61ae58c4385ef_8575748239302698718.cpython-36m-x86_64-linux-gnu.so

@vavlopes
Copy link

I have also downgraded the package to the previous 0.3.post2. It worked but what I wanted is to upgrade the package to the newest version. I'm facing other problems, probably related to few data points in the time series, that I was hoping to fix using this new version....But yes, if you downgrade to 0.3.post2 you can still use the package.

@billhumanlytics
Copy link

Installing with conda install -c conda-forge fbprophet worked for me. It seems that this error is caused by some missing dependencies or incorrect version on some dependencies.

nabeel-oz pushed a commit to nabeel-oz/qlik-py-tools that referenced this issue Jan 2, 2019
New release of fbprophet results in an error. Added fix to Qlik-Py-Init.
facebook/prophet#775
@ckuehl
Copy link

ckuehl commented Jan 2, 2019

Can this issue please be reopened? I'm seeing the same issue and had to pin to 0.3.post2.

@Gordonei
Copy link
Contributor

Gordonei commented Jan 3, 2019

As @bletham suggested, I've found that if I install/build using pip3 install --no-cache-dir --no-binary :all: fbprophet, it works in Ubuntu 18.04 (deploying inside docker).

Unfortunately, the --no-binary :all: option does mean that all uninstalled requirements will be built from source. I found the convertdate package wasn't building, and hence, I had to install it first (pip3 install convertdate) - YMMV.

@ivonnics
Copy link

ivonnics commented Jan 4, 2019

I am having exactly the same roblem when I instantiate the prophet model with:
m = Prophet()
m.fit(df)
I got:
AttributeError Traceback (most recent call last)
<ipython-input-15-1ab3c9387252> in <module>
1 m = Prophet()
----> 2 m.fit(df)

~\Anaconda3\envs\PystanandProphet\lib\site-packages\fbprophet\forecaster.py in fit(self, df, **kwargs)

~\Anaconda3\envs\PystanandProphet\lib\site-packages\pystan\model.py in optimizing(self, data, seed, init, sample_file, algorithm, verbose, as_vector, **kwargs)
470 data = {}
471 seed = pystan.misc._check_seed(seed)
--> 472 fit = self.fit_class(data, seed)
473
474 m_pars = fit._get_param_names()

AttributeError: 'StanModel' object has no attribute 'fit_class'
I tried to install fbprophet 0.3.post2, , but got the same...
Any suggestion?

@windmac
Copy link

windmac commented Jan 4, 2019

I've just solved this problem before a minute by following this instruction to install gcc 64 to my computer:
https://wiki.python.org/moin/WindowsCompilers
Then create a new empty environment in Anaconda and install fbprophet directly by:
conda install -c conda-forge fbprophet
Finally it works, hope it can help :)

@ivonnics
Copy link

ivonnics commented Jan 4, 2019

I had to downgrade from prophet 0.4 to 0.3 by using the prophet version included in Conda-forge

As suggested by @windmac I just created a new empty environment in Anaconda and installed fbprophet directly by using:

  1. conda config --add channels conda-forge
  2. conda install fbprophet

Please, notice that I did not install gcc 64 in my computer, as I had the C++ Building Tools already installed in Visual Studio 2017 !!!
Now Prophet is working OK 😁

@robomotic
Copy link

I am not sure why this has been closed, there doesn't seem to be a solution to use the latest 0.4 version which has the nice add_holiday functionality.
Am I missing something?

@bletham bletham reopened this Jan 5, 2019
@bletham bletham added the bug label Jan 5, 2019
@seanjtaylor
Copy link
Contributor

Sorry guys I built a wheel on OS X but it was not labeled correctly. I have removed it from PyPI so if you reinstall everything should be fixed.

@seanjtaylor
Copy link
Contributor

I'm going to do a post release soon so that people's package managers are forced to upgrade. Apologies again for the inconvenience, I'm not sure why when I built the wheel that it didn't create the right file name.

@leonardonh
Copy link

leonardonh commented Jan 7, 2019

Hi.

I'm still not able to import fbprophet 0.4. I got the error in holidays #792:
ImportError: cannot import name 'MONDAY'

I downgraded fbprophet to 0.3.post2, so I no longer got the holidays issue. Instead, I got the Stan error:
AttributeError: 'StanModel' object has no attribute 'fit_class'

I tried downgrading Stan, but without success.

@bletham
Copy link
Contributor

bletham commented Jan 8, 2019

@leonardonh see #796, this is due to a recent change in the 'holidays' package and can be fixed by downgrading that package as described in #796, while we push out the fix with the new imports.

@leonardonh
Copy link

I forgot to mention that I have already tried to downgrade holidays
!pip install holidays==0.9.8 --no-cache
and also to older versions, but couldn't manage to make it work.

Untill Thursday it was working. I'm running it on Google Colab, so you can replicate the error on the same enviroment.

@bletham
Copy link
Contributor

bletham commented Jan 8, 2019

Thursday is when v0.9.9 of holidays was released, but we'll push out the post release that fixes this on our side very soon.

@bletham bletham added the ready label Jan 8, 2019
@bletham
Copy link
Contributor

bletham commented Jan 8, 2019

The fix has been pushed to pypi.

pip install --upgrade fbprophet

will get things working.

@leonardonh
Copy link

Great! Thanks @bletham. It's working.

@ivonnics
Copy link

ivonnics commented Jan 9, 2019

Great news....
Installed &, tested, so I can now give testimony and confirm that Prophet 0.4 is running well!!!!
😃 😁 😆

@seanjtaylor
Copy link
Contributor

Post release is out. Closing the issue.

@Okroshiashvili
Copy link
Contributor

I have the same issue.

Prophet version 1.0
Ubuntu 18.04
Python 3.7

WARNING:pystan:numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject WARNING:pystan:Something went wrong while unpickling the StanModel. Consider recompiling.

ngupta23 added a commit to pycaret/pycaret that referenced this issue Mar 14, 2022
@yunis99wirkus
Copy link

Worked for me with following configuration:

OS: MacOS 12.4 Monterey (Apple M1 Pro; so all the Arm64 builts for compilers, used clang as C++ compiler)
cmdstanpy 0.9.68 (pip installed)
prophet 1.0 (pip installed)
pystan 2.19.1.1 (conda-forge installed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests