Prophet: Error: package or namespace load failed for ‘prophet’ in dyn.load(file, DLLpath = DLLpath, ...)

Created on 17 Aug 2020  Â·  6Comments  Â·  Source: facebook/prophet

Great package. I have integrated into modeltime (R package that uses prophet with tidymodels ecosystem). It's working great.

I did run into one issue when using on MacOS (Windows I have not experienced this problem). I've referenced the issue business-science/modeltime#20.

Problem

MacOS seems to have an issue (sometimes???) when loading prophet.

> library(prophet)
Loading required package: Rcpp
Loading required package: rlang
Error: package or namespace load failed for ‘prophet’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/prophet/libs/prophet.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/prophet/libs/prophet.so, 6): Library not loaded: @rpath/libtbb.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/prophet/libs/prophet.so
  Reason: image not found

Solution

The easiest way to fix is to load StanHeaders.
This sets the C++ flags and libraries, which seems to solve the missed libtbb.dylib path.

How I solved it with modeltime:

Add StanHeaders to Imports
image

Somewhere in the package import StanHeaders.

image

The same solution will work for prophet.

Most helpful comment

Hey @seanjtaylor & @bletham - I checked and this fixes the issues. Thanks for merging. I just had another student with the same issue.

All 6 comments

Thanks for raising the issue. This issue actually cropped up for a few people recently (#1601, #1604, #1608). I haven't run into it myself so haven't been able to do much by way of thorough investigation, but in #1604 I wondered if it could be something with the model not compiling properly, so I recommended re-installing prophet from source, and that seemed to work in that case. #1608 also fixed it with package upgrades (of dependencies, but maybe prophet was re-installed as part of that?).

But to clarify one point: it seems that you added StanHeaders to the imports for the modeltime package and that fixed the error that was being raised when it imported prophet. Did you by chance try adding it directly to prophet to verify that fixes it? Once I replicate the error I could try that myself, but I'm not really sure of the source of the error. It'd be great to have a solution for this other than the re-install-from-source that seemed to work once.

Hey Ben,

Yes - I can do this. I know it will work because I've been doing it manually:

library(StanHeaders)
library(prophet)

Works fine on my machine. And all StanHeaders does is generate the C++ bindings for Rcpp & Stan (so it's super lightweight).

I have a stacked schedule but hopefully by weekend I can send a PR addressing this.

Thanks! Great to know the workaround too.

@bletham PR #1643 fixes this issue.

image

Oops I asked in the PR, but got the answer here. Nevermind!

Hey @seanjtaylor & @bletham - I checked and this fixes the issues. Thanks for merging. I just had another student with the same issue.

Was this page helpful?
0 / 5 - 0 ratings