All Products
Search
Document Center

Elastic Compute Service:FAQs about installing Alibaba Cloud SDK for Python on a Linux ECS instance

Last Updated:Nov 21, 2024

This topic describes common installation issues of Alibaba Cloud SDK for Python on a Linux Elastic Compute Service (ECS) instance and provides corresponding solutions.

Issues

FAQs and solutions

Issue 1: How do I check the minimum Python version required for using Alibaba Cloud SDK for Python?

The minimum Python version required for using Alibaba Cloud SDK for Python is based on the end-of-life dates for all Python versions that Python Software Foundation (PSF) publishes. Visit the OpenAPI portal to verify the specific version requirements for Python.image

Issue 2: Error message "Command "python setup.py egg_info" failed with error code 1 in XX" is displayed when I install the SDK.

This error arises from an outdated Python or pip version, or the absence of required dependencies. To resolve this issue, apply the following methods:

  1. Verify the Python version.

    Check that your Python version satisfies the requirements of Alibaba Cloud SDK for Python by running python -V or python3 -V on your ECS instance. If the version is incompatible, install the latest Python version. For information about Python installation guidance, see Issue 4: How do I install Python3?

  2. Update pip if the Python version is compatible.

    Using the most recent pip version can prevent certain common issues. Update pip with pip install --upgrade pip and try to install the SDK again.

Issue 3: Error message "ModuleNotFoundError: No module named 'XX'" is displayed when I install the SDK.

This error indicates missing dependency libraries. Resolve it by running the pip install XX command.

Issue 4: How do I install Python3?

To install Python3 on CentOS, follow the steps below. For more information about Python3 installation methods, see Install Python on Linux.

  1. Obtain the latest Python source package from the official Python website. Run the following commands to download and extract it. In this example, Python 3.11.10 is used.

    wget https://www.python.org/ftp/python/3.11.10/Python-3.11.10.tgz
    tar -xzvf Python-3.11.10.tgz
  2. Before compiling Python, ensure that you have installed the required dependency libraries and tools.

    sudo yum -y install gcc
    sudo yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel libpcap-devel xz-devel libffi-devel
  3. Navigate to the source directory to configure and compile Python.

    cd Python-3.11.10
    ./configure --prefix=/usr/python 
    make && sudo make altinstall
  4. Run the which python3 pip3 command to verify the presence of symbolic links for python3 and pip3 in the current system. If these symbolic links exist, they must be removed.image

    sudo rm -rf /usr/bin/python3 /usr/bin/pip3
  5. Create new symbolic links for python3 and pip3 to the executable files.

    Note

    Symbolic links act as shortcuts to files or directories, enabling quick access. For example, running python3 actually runs the python 3.11 interpreter.

    sudo ln -s /usr/python/bin/python3 /usr/bin/python3
    sudo ln -s /usr/python/bin/pip3 /usr/bin/pip3
  6. Confirm the installed Python version.

    python3 -V
    pip3 -V

    image

Issue 5: How to upgrade Python2 to Python3?

Install the desired version of Python 3.XX.XX on your ECS instance. Once installed, Python3 commands will be available for use. For detailed installation instructions, refer to Issue 4: How to install Python3.