user3792245
user3792245

Reputation: 828

Importing fbprophet as a AWS Lambda layer

Unable to package fbprophet into a layer that can be imported in to AWS Lambda. Need help with it.

My local computer is a Mac with Sierra installed. I am trying to create layers for different libraries that get used in Python 3 as part of the AWS Lambda serverless architecture. I have been successful packaging the Pandas library and imported it as a layer. But, when I try a similar approach for fbprophet, it is failing.

Error:

ModuleNotFoundError: No module named 'pystan'

I am using a script that reads from a requirements file and installs the different modules listed in there. Here is the code for the script:

#!/bin/bash

export PKG_DIR="python"

docker run --rm -v $(pwd):/foo -w /foo lambci/lambda:build-python3.6 \
pip install -r requirements.txt -t ${PKG_DIR}

The requirements.txt file looks as follows: fbprophet==0.5

However, when I try fbprophet installation, it fails saying:

ModuleNotFoundError: No module named 'pystan'

I was expecting that fbprophet would be installed, which could be zipped and used as a layer on Lambda, but unable to proceed beyond the current point. Help in resolving this would be much appreciated! Thank you.

Upvotes: 0

Views: 860

Answers (1)

user3792245
user3792245

Reputation: 828

Figured out that it was due to gcc compiler being not compatible that the fbprophet was not getting compiled and getting packaged into a AWS Lambda layer. Created a virtual environment and installed gcc using conda, as follows:

conda install clang_osx-64 clangxx_osx-64 -c anaconda

Then, followed the steps in this article: https://towardsdatascience.com/how-to-get-fbprophet-work-on-aws-lambda-c3a33a081aaf

This got fbprophet installed and I was able to package it and upload as a Lambda layer.

Upvotes: 0

Related Questions