This topic describes common issues and their solutions when installing the Alibaba Cloud SDK for Python on a Linux ECS instance.
Questions
Questions and answers
Question 1: What is the minimum Python version?
The required Python version for the Alibaba Cloud SDK for Python is determined by the official end-of-life schedule for each Python version. You can visit the OpenAPI Portal
OpenAPI Portal to view the minimum version requirement. On the Elastic Compute Service (ECS) page in the Alibaba Cloud SDK Center, select V2.0 (Recommended) as the SDK generation and Python as the language. Go to the Quick Start tab. In the Prerequisites section, you can find that the minimum version requirement is Python >= 3.7.
Question 2: Resolve the "egg_info failed" error
This issue is typically caused by an outdated Python or pip version, or by a missing dependency. Follow these steps to troubleshoot and resolve the issue:
-
Check your Python version.
Ensure your Python version meets the SDK's requirements. Run the
python -Vorpython3 -Vcommand on your ECS instance to check the installed version. If the version is incompatible, install a newer one. For more information, see Question 4: How do I install Python 3?. -
If your Python version is compatible, upgrade pip.
An outdated pip version can cause known issues. Run
pip install --upgrade pipto upgrade it, and then try installing the SDK again.
Question 3: Resolve the "ModuleNotFoundError" error
This error indicates that a required dependency is missing. Run pip install XX to install it.
Question 4: How do I install Python 3?
To install Python 3 on CentOS, follow these steps. For more information about how to install Python 3, see Install Python on Linux.
-
Visit the official Python website to get the download link for the latest source code package. The following example shows the commands to download and decompress Python 3.11.10.
wget https://www.python.org/ftp/python/3.11.10/Python-3.11.10.tgz tar -xzvf Python-3.11.10.tgz -
Before you compile Python, install the necessary dependencies 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 -
Navigate to the source code directory to configure and compile.
cd Python-3.11.10 ./configure --prefix=/usr/python make && sudo make altinstall -
Run
which python3 pip3to check if symbolic links for python3 and pip3 exist. If they do, you must remove them.[root@xxx]# which python3 pip3 /usr/bin/python3 /usr/bin/pip3sudo rm -rf /usr/bin/python3 /usr/bin/pip3 -
Create new symbolic links to point
python3andpip3to the new executable files.NoteSymbolic links act as shortcuts to files or directories for quick access. For example,
python3can point to thepython3.11interpreter.sudo ln -s /usr/python/bin/python3.11 /usr/bin/python3 sudo ln -s /usr/python/bin/pip3.11 /usr/bin/pip3 -
Check the installed Python version.
python3 -V pip3 -V[root@iZxxx ~]# python3 -V Python 3.11.10 [root@iZxxx ~]# pip3 -V pip 24.0 from /usr/python/lib/python3.11/site-packages/pip (python 3.11)
Question 5: Upgrade from Python 2 to Python 3
Instead of upgrading Python 2, install Python 3 to run alongside it. After installation, use the python3 and pip3 commands. For more information about how to install Python 3, see Question 4: How do I install Python 3?.