Help Center/ FunctionGraph/ Developer Guide/ Python/ Creating a Dependency
Updated on 2024-11-11 GMT+08:00

Creating a Dependency

You are advised to create function dependencies in Huawei Cloud EulerOS 2.0. If other OSs are used, an error may occur due to underlying dependent libraries. For example, the dynamic link library cannot be found.

  • If the modules to be installed need dependencies such as .dll, .so, and .a, archive them to a .zip package.

Creating a Dependency for a Python Function

Ensure that the Python version of the packaging environment is the same as that of the function. For Python 2.7, Python 2.7.12 or later is recommended. For Python 3.6, Python 3.6.3 or later is recommended.

To install the PyMySQL dependency for a Python 2.7 function in the local /tmp/pymysql directory, run the following command:

pip install PyMySQL --root /tmp/pymysql

After the command is successfully executed, go to the /tmp/pymysql directory:

cd /tmp/pymysql/

Go to the site-packages directory (generally, usr/lib64/python2.7/site-packages/) and then run the following command:

zip -rq pymysql.zip *

The required dependency is generated.

To install the local wheel installation package, run the following command:

pip install piexif-1.1.0b0-py2.py3-none-any.whl --root /tmp/piexif   
//Replace piexif-1.1.0b0-py2.py3-none-any.whl with the actual installation package name.