create requirements.txt
pip freeze> requirements.txt
create a folder with all the dependencies:
pip install -t vendored -r requirements.txt
Please note that to use these dependencies in your code, you need to add the following:
import os import sys here = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(here, "./vendored"))
See fooobar.com/questions/718309 / ... for another example.
UPDATE: Instead of marker (2) and the above code, you can now use the serverless-python-requirements plugin:
install plugin
npm install
and add the plugin to your serverless.yml
plugins: - serverless-python-requirements
Remember to make sure you have a requirements.txt file.
So that as soon as sls deploy is called, the plugin will pack dependencies with the code.
For a complete example, take a look at serverless-python-sample .
source share