Function Compute provides built-in common dependencies for you to reference in the runtime environment. Function Compute also supports third-party dependencies. This topic describes how to install third-party dependencies on Function Compute.

Background information

For more information about the common dependencies that are built in Function Compute, see the "Use built-in modules" section of the following topics:

Installation guide

You can install third-party dependencies by using one of the following methods:

  • Use the Function Compute console:
    • Install the dependencies by using a code package.
      1. Compress the third-party dependencies and code files into a package.
        Notice
        • You must compress all the files in the code directory into a package. After you compress the files, make sure that the files of the handler function are placed in the root directory of the package.
        • The packaging method varies with the operating system. Select a feasible packaging method as needed.
      2. Log on to the Function Compute console and upload a code package by Upload a zip package, Upload a folder, or Upload through OSS to deploy the function.
    • Install the dependencies by using a terminal.
      If you use the new version of the online code editor in the Function Compute console, you can run the dependency installation command on the terminal on the Code tab to install the dependencies. For example, Python is used. Run the following command on the terminal in the new version of the online code editor to install the dependencies:
      pip install -t . demo // The demo is the file name of the PIP package. Before you run this command, you must replace the demo with the file name of the PIP package.  
      Notice If you need to use the new version of the online code editor as a RAM user, make sure that the AliyunRDCDevStudioRole policy is attached to the RAM user by using the Alibaba Cloud account to which the RAM user belongs. After the policy is attached, Function Compute can help you create an Apsara Devops account and initialize an Apsara DevOps organization workspace. For more information about the policy, see Policies and sample custom policies.
  • Use Serverless Devs to install: Create and deploy functions by using Function Compute Serverless Devs. For more information, see Examples of installing dependencies in various runtime environments.

References

For more information about how to install third-party dependencies in different runtime environments, see the "Use custom modules" section of the following topics: