Skip to content

Commit f96345a

Browse files
committed
update Linux part of python-install blog
1 parent 319c012 commit f96345a

2 files changed

Lines changed: 115 additions & 8 deletions

File tree

content/en/post/python-install/index.md

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ To check if your macOS has Python installed, open Terminal and do something like
192192
- Run `python3 --version` If the version is 3.x.*, Python 3 is pre-installed
193193
194194
> **Note:**
195-
> Recent versions of macOS include a **python3** command in `/usr/bin/python3` that links to a usually older and incomplete version of Python provided by and for use by the Apple development tools, **Xcode** or the **Command Line Tools for Xcode**
196-
> You should never modify or attempt to delete this installation, as it is Apple-controlled and is used by Apple-provided or third-party software
197-
> If you choose to install a newer Python version from `python.org`, you will have two different but functional Python installations on your computer that can co-exist
195+
> Recent versions of macOS include a **python3** command in `/usr/bin/python3` that links to a usually older and incomplete version of Python provided by and for use by the Apple development tools, **Xcode** or the **Command Line Tools for Xcode**<br>
196+
> You should never modify or attempt to delete this installation, as it is Apple-controlled and is used by Apple-provided or third-party software<br>
197+
> If you choose to install a newer Python version from `python.org`, you will have two different but functional Python installations on your computer that can co-exist<br>
198198
> The default installer options should ensure that its **python3** will be used instead of the system **python3**
199199
200200
Here are a few common installation methods for Python, and you can choose the one that suits you according to your needs.
@@ -242,4 +242,59 @@ To install Python on macOS using Homebrew, follow these steps:
242242
![Install Python](18.png)
243243
4. Run Brew Link Python or Brew Link python@3. XX (replace XX with the correct version number) - Then restart the Terminal application to make sure the application is working properly
244244
![Link Python](19.png)
245-
5. Once the installation is complete, you can run the `python -–version` or `python3 –-version` command to verify the installation
245+
5. Once the installation is complete, you can run the `python -–version` or `python3 –-version` command to verify the installation
246+
247+
248+
## Linux
249+
The simplest way to install Python on a Linux system is to use the package manager. Below are methods for installing Python with different package managers:
250+
251+
### Debian / Ubuntu / Mint
252+
For Debian / Ubuntu / Mint systems, Python is typically installed using the apt package manager:
253+
254+
```bash
255+
sudo apt update # Refresh the system's package database to ensure you get the latest versions
256+
sudo apt upgrade # Update all installed packages to their latest versions to avoid compatibility issues
257+
sudo apt install python3 # Install Python 3
258+
sudo apt install python3-pip # Install Python 3's pip package manager
259+
sudo apt install python3-dev python3-venv build-essential # Install Python3 development tools and virtual environment
260+
sudo chown -R $USER:$USER ~/.local # Resolve permission issues
261+
sudo rm /var/lib/apt/lists/lock
262+
sudo rm /var/cache/apt/archives/lock # Resolve lock file issues
263+
```
264+
265+
### CentOS / Fedora / Red Hat
266+
267+
#### yum
268+
For older CentOS / Fedora / Red Hat systems, Python is typically installed using the yum package manager:
269+
```bash
270+
sudo yum update # Refresh the system's package database for the latest versions
271+
sudo yum install epel-release # Install the EPEL repository (optional)
272+
sudo yum install python3 # Install Python3
273+
sudo yum clean all
274+
sudo yum repolist # Clean and validate repository configuration
275+
```
276+
277+
#### dnf
278+
For newer CentOS / Fedora / Red Hat systems, Python is typically installed using the dnf package manager:
279+
```bash
280+
sudo dnf update # Refresh the system's package database to obtain the latest versions
281+
sudo dnf install python3 # Install Python3
282+
sudo dnf groupinstall “Development Tools” # Install development tools
283+
sudo dnf install python3-pip # Install Python3's pip package manager
284+
```
285+
286+
### Arch Linux
287+
For Arch Linux systems, Python is typically installed using the pacman package manager:
288+
```bash
289+
sudo pacman -Syu # Refresh the system's package database to obtain the latest versions
290+
sudo pacman -S python python-pip # Install Python3 and the pip package manager for Python3
291+
```
292+
293+
### SUSE / openSUSE
294+
For SUSE / openSUSE systems, Python is typically installed using the zypper package manager:
295+
```bash
296+
sudo zypper refresh # Refresh the system's package database to obtain the latest versions
297+
sudo zypper install python3 python3-pip # Install Python 3 and the pip package manager for Python 3
298+
sudo zypper install python3-devel python3-virtualenv build-essentials # Install Python 3 development tools and virtual environments
299+
```
300+

content/zh-cn/post/python-install/index.md

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ Python是一种解释型、高级和通用的编程语言。Python的设计理
178178
- 运行 `python3 --version` 如果显示版本为 3.x.*,说明系统预装了Python 3
179179
180180
> **注意:**
181-
> 最近几个版本的 macOS 都包括一个 **python3** 命令 `/usr/bin/python3`,它链接到一个供 Apple 开发工具 **Xcode** 或 **Command Line Tools for Xcode** 使用的通常较老旧且不完整的 Python 版本
182-
> 你绝不应该修改或试图删除此安装版,因为它是由 Apple 控制且由 Apple 提供的或第三方的软件所使用
183-
> 如果你选择安装一个来自 `python.org` 的更新的 Python 版本,在你的计算机上将有两个不相同但均能正常运行的 Python 安装版共存
181+
> 最近几个版本的 macOS 都包括一个 **python3** 命令 `/usr/bin/python3`,它链接到一个供 Apple 开发工具 **Xcode** 或 **Command Line Tools for Xcode** 使用的通常较老旧且不完整的 Python 版本<br>
182+
> 你绝不应该修改或试图删除此安装版,因为它是由 Apple 控制且由 Apple 提供的或第三方的软件所使用<br>
183+
> 如果你选择安装一个来自 `python.org` 的更新的 Python 版本,在你的计算机上将有两个不相同但均能正常运行的 Python 安装版共存<br>
184184
> 默认安装程序选项应当会确保使用它的 **python3** 而不是系统的 **python3**
185185
186186
下面是Python的几种常见安装方式,您可以根据需要选择适合自己的安装方式。
@@ -228,4 +228,56 @@ Python是一种解释型、高级和通用的编程语言。Python的设计理
228228
![安装python](18.png)
229229
4. 运行 brew link python 或 brew link python@3.XX (将 XX 替换为正确的版本号)- 然后重新启动「终端」应用程序,以确保应用程序正常工作
230230
![链接python](19.png)
231-
5. 安装完成后,可以运行 `python -–version``python3 –-version` 命令来验证安装
231+
5. 安装完成后,可以运行 `python -–version``python3 –-version` 命令来验证安装
232+
233+
## Linux
234+
在 Linux 系统上安装 Python 的最简单方法是使用包管理器。下面是不同包管理器安装Python 的方法:
235+
236+
### Debian / Ubuntu / Mint
237+
对于Debian / Ubuntu / Mint系统,一般使用 apt 包管理器来安装 Python:
238+
```bash
239+
sudo apt update #刷新系统的软件包数据库,以确保您获得最新版本
240+
sudo apt upgrade #将所有已安装的软件包更新至最新版本,避免兼容性问题
241+
sudo apt install python3 #安装Python3
242+
sudo apt install python3-pip #安装Python3的 pip 包管理器
243+
sudo apt install python3-dev python3-venv build-essential #安装Python3的 开发工具 和 虚拟环境
244+
sudo chown -R $USER:$USER ~/.local #解决权限问题
245+
sudo rm /var/lib/apt/lists/lock
246+
sudo rm /var/cache/apt/archives/lock # 解决锁文件问题
247+
```
248+
249+
### CentOS / Fedora / Red Hat
250+
251+
#### yum
252+
对于早期的 CentOS / Fedora / Red Hat 系统,一般使用 yum 包管理器来安装 Python:
253+
```bash
254+
sudo yum update #刷新系统的软件包数据库,以获得最新版本
255+
sudo yum install epel-release # 安装 EPEL 源(可选)
256+
sudo yum install python3 # 安装 Python3
257+
sudo yum clean all
258+
sudo yum repolist # 清理并验证存储库配置
259+
```
260+
261+
#### dnf
262+
对于较新的 CentOS / Fedora / Red Hat 系统,一般使用 dnf 包管理器来安装 Python:
263+
```bash
264+
sudo dnf update # 刷新系统的软件包数据库,以获得最新版本
265+
sudo dnf install python3 # 安装 Python3
266+
sudo dnf groupinstall "Development Tools" # 安装开发工具
267+
sudo dnf install python3-pip # 安装 Python3 的 pip 包管理器
268+
```
269+
270+
### Arch Linux
271+
对于 Arch Linux 系统,一般使用 pacman 包管理器来安装 Python:
272+
```bash
273+
sudo pacman -Syu # 刷新系统的软件包数据库,以获得最新版本
274+
sudo pacman -S python python-pip # 安装 Python3 和 Python3 的 pip 包管理器
275+
```
276+
277+
### SUSE / openSUSE
278+
对于 SUSE / openSUSE 系统,一般使用 zypper 包管理器来安装 Python:
279+
```bash
280+
sudo zypper refresh # 刷新系统的软件包数据库,以获得最新版本
281+
sudo zypper install python3 python3-pip # 安装 Python3 和 Python3 的 pip 包管理器
282+
sudo zypper install python3-devel python3-virtualenv build-essentials # 安装 Python3 的开发工具和虚拟环境
283+
```

0 commit comments

Comments
 (0)