All Products
Search
Document Center

:How to handle the "No module named oss2" error when you use OSS by using Python

Last Updated:Mar 14, 2023

Important

This article may be contributed by a community or involve information about third-party products. We recommend that you visit the official website of the community or third-party products for help and support. Third-party products are not covered by Alibaba Cloud after-sales support. This article is only for reference. Alibaba Cloud does not make any implication or other forms of commitment.

Problem description

The oss2 module is called when you upload or download resources in Object Storage Service (OSS) by using Python. The "No module named oss2" error occurs after your Python script file is run.

Cause

OSS SDK for Python and the oss2 module are not installed in the system environment.

Solution

  1. Take the Linux operating system as an example. Run the following command in the script file environment to install the python-devel development package:

    sudo yum install -y python-devel

  2. Run the following commands in sequence to install the oss2 module:

    sudo yum install -y epel-release
    sudo yum install -y python-pip
    pip install oss2

  3. After you install the oss2 module, confirm that your Python script file can be run normally.

Application scope

  • OSS