Setting Up a Python Environment
Overview
Python is a widely used interpretive, high-level, and general programming language. Python supports multiple programming paradigms, including structured, procedural, reflective object-oriented, and functional programming. It employs a dynamic type system and automatic garbage collection to manage memory efficiently. It has a large and comprehensive standard library. Its language structure and object-oriented method are designed to help programmers write clear, logical code for small and large projects.
This section describes how to set up a Python environment on an ECS.
Prerequisites
- The ECS has an EIP bound.
- The rule listed in the following table has been added to the security group which the target ECS belongs to. For details, see Adding a Security Group Rule.
Table 1 Security group rule Direction
Priority
Action
Type
Protocol & Port
Source
Inbound
1
Allow
IPv4
TCP: 80
0.0.0.0/0
Deploying Python
Perform the corresponding operations based on the operating system.
CentOS 8.0
- Visit the Python official website, hover the cursor over Downloads, and click Source code.
- Select the Python version to be installed, copy the download link, and run the following commands to download and decompress the package. In this example, Python 3.9.22 is installed.
wget https://www.python.org/ftp/python/3.9.22/Python-3.9.22.tgz tar xzf Python-3.9.22.tgz cd Python-3.9.22
- Run the following commands to install the dependencies:
sudo yum groupinstall -y "Development Tools" sudo yum install -y python3-devel
- Run the following commands to compile and install the software:
./configure --enable-optimizations make -j $(nproc) sudo make altinstall
- Run the following command to view the installation result:
python3.9 --version
Ubuntu 22.04
- Visit the Python official website, hover the cursor over Downloads, and click Source code.
- Select the Python version to be installed, copy the download link, and run the following commands to download and decompress the package. In this example, Python 3.9.22 is installed.
wget https://www.python.org/ftp/python/3.9.22/Python-3.9.22.tgz tar -xzf Python-3.9.22.tgz
- Run the following commands to install the dependencies:
sudo apt update sudo apt install -y build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libbz2-dev libffi-dev zlib1g-dev
- Run the following commands to compile and install the software:
cd Python-3.9.22 ./configure --enable-optimizations make -j $(nproc) sudo make altinstall
- Run the following command to view the installation result:
python3.9 --version
Windows 2022
- Visit the Python official website, hover the cursor over Downloads, and click Windows.
- Select the Python version to be installed, for example, Python 3.13.2. Click Download Windows installer (64-bit) to download the installation file.
- Double-click the downloaded installation file python-3.13.2-amd64.exe to start the installation.
- Select Customize installation and Add python.exe to PATH.
- Click Next.
- Change the installation path and click Install.
- After the installation is complete, open the CLI, enter python, and press Enter. If the following information is displayed, Python has been installed.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot