All Products
Search
Document Center

Function Compute:Install third-party dependencies

Last Updated:Apr 14, 2026

Function Compute runtimes include built-in dependencies that you can use in your functions. If these dependencies do not meet your requirements, you can install third-party dependencies. This topic describes how to install them.

Background information

To view the dependencies built into Function Compute, see the built-in modules section in the following documents.

Install dependencies with layers

Function Compute provides official public layers preinstalled with common dependencies. You can use these layers directly or build a custom layer to install specific dependencies. For more public layers, see awesome-layers.

Use public layers

  • Official public layers

    Log on to the Function Compute console and navigate to the Configuration tab for your function. In the Advanced Settings section, click Modify. In the Advanced Settings panel, select Add Custom Layer. This corresponds to item ① in the figure.

  • Community public layers

    Find your desired layer in awesome-layers and copy its layer ARN. On the function's details page, navigate to the Configuration tab. In the Advanced Settings section, click Modify. In the Advanced Settings panel, select Add Layer by ARN. This corresponds to item ② in the figure.

image

Build custom layers

  • Build a layer in the console

    Log on to the Function Compute console. In the left-side navigation pane, choose Advanced Features > Layers. For detailed instructions, see Create a custom layer.

    Note

    This method does not support dependencies that contain a dynamic-link library (.so file), such as the Puppeteer library for Node.js. If your dependency includes a dynamic-link library, we recommend building the layer by using a Dockerfile.

  • Build a layer locally

    You can build a custom layer directly on your local machine. For detailed instructions, see Build a ZIP package for a layer. When using this method, your local machine's operating system and processor architecture must match the function's runtime environment (x86_64 Linux). This match is not required if the installed dependencies are platform-agnostic. Otherwise, we recommend building the layer in the console or building the layer by using a Dockerfile.

    For example, the Python scientific computing library numpy depends on the underlying environment. You cannot build a layer with this library locally on a Mac computer with an M1 chip.

  • Build a layer by using a Dockerfile

    If a dependency contains a dynamic-link library or fails to install locally, use a Dockerfile to build the layer. For detailed instructions, see How to build a layer based on a Dockerfile.

Install dependencies in the console

Package and upload to the console

  1. Package all files in your code directory. Ensure the function handler file is at the root of the resulting package.

    Important
    • Go to the code directory and package all the files. The function handler file must be in the root directory of the package.

    • The packaging method depends on your operating system.

  2. Log on to the Function Compute console and find your function. On its details page, upload your code package by selecting Upload ZIP Package, Upload Folder, or Upload Package Using OSS, and then click Deploy.

Use the Web IDE terminal

  1. Log on to the Function Compute console and find your function.

  2. On the function's details page, click the Code tab. In the Web IDE, select . In the terminal window, run the following command to install the dependency: pip install -t . <PackageName>

    pip install -t . <PackageName> # Replace <PackageName> with your dependency name. The -t . flag installs the package into the current directory.
  3. Click Deploy to apply the changes.

Install dependencies with Serverless Devs

You can use Function Compute to create and deploy your functions. For detailed instructions, see Common Serverless Devs commands.