From ba7b6fdec5962eaba5292a002d14251a65f0070e Mon Sep 17 00:00:00 2001 From: hf_trixie Date: Sat, 15 Aug 2026 01:18:51 +0800 Subject: 审查并修改_1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/applications/programming/python.md | 93 ++------------------------------- 1 file changed, 5 insertions(+), 88 deletions(-) (limited to 'docs/applications/programming/python.md') diff --git a/docs/applications/programming/python.md b/docs/applications/programming/python.md index 1180d39..bbc0af9 100644 --- a/docs/applications/programming/python.md +++ b/docs/applications/programming/python.md @@ -1,93 +1,10 @@ -# Python +# Python开发套件 -## 安装 Python +## Python3 -Linux 上装Python还是非常轻松的,因为不用装,大部分发行版自带。 +### 安装 -Linux 里面一般都是 `python3`。 -如果你想要用 `python` 这个命令, 可以装一个 `python-is-python3`, 来用软链接骗过操作系统(开个玩笑)。 +无须安装,发行版自带。 -- Debian: `sudo apt install python-is-python3 -y` -- Fedora: `sudo dnf install python-is-python3 -y` +Linux里面一般以`python3`命令使用Python。 -## 编写第一个脚本 - -- 创建一个脚本 - -```bash -touch hello.py -``` - -- 写入内容 - -```bash -echo "print('hello python')" > hello.py -``` - -- 查看内容 - -```bash -cat hello.py - -# 会输出 -# print('hello python') -``` - -## 运行 - -有很多Windows来的同志不知道怎么运行,但实际上非常简单。 - -用法: - -```bash -# python <要运行的脚本路径> - -python hello.py -``` - -这样你就成功运行起 Python 脚本了。 -实际上就是给 Python 指定需要运行的文件, 就这么简单。 - -恭喜你在Linux上成功运行了Python脚本。 - -## 编辑器 - -- 如果你使用WSL, 推荐使用 VSCode 的 WSL 插件来连接写代码, 当然勇敢牛牛可以尝试 LazyVim 写代码 -- 如果你使用原生 Linux, 还是这两种推荐haha - -VSCode 资料很多, 我也用的比较少,可以直接上Bilibili搜索VSCode Python环境搭建 -[LazyVim入坑视频](https://www.bilibili.com/video/BV1TJCvYFE2T?t=286.5) - -## 库 - -Python拥有规模庞大的PyPi库。通常,我们使用`pip`进行安装。但在Linux下,`pip`不一定会随着Python预装,因此需要使用包管理器安装。 - -- Debian: `sudo apt install python3-pip` -- Fedora: `sudo dnf install python3-pip` -- Arch: `sudo pacman -S python-pip` - -!!! warning "系统依赖" - 使用Pip安装部分库时,可能会出现如下警告: - ``` - error: externally-managed-environment - - × This environment is externally managed - ╰─> To install Python packages system-wide, try 'pacman -S - python-xyz', where xyz is the package you are trying to - install. - - If you wish to install a non-Arch-packaged Python package, - create a virtual environment using 'python -m venv path/to/venv'. - Then use path/to/venv/bin/python and path/to/venv/bin/pip. - - If you wish to install a non-Arch packaged Python application, - it may be easiest to use 'pipx install xyz', which will manage a - virtual environment for you. Make sure you have python-pipx - installed via pacman. - - note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. - hint: See PEP 668 for the detailed specification. - ``` - 由于系统的部分组件依赖Python的依赖,因而外来库可能破坏系统本身的依赖关系。 - - 这个时候,我们建议您使用`venv`创建虚拟环境,或者寻找发行版的软件源是否有对应的库可供安装(一般包名为`python3-库`或`python-库`)。 \ No newline at end of file -- cgit v1.3 From 33830d56659c215d054012b402a96bcb6b297c14 Mon Sep 17 00:00:00 2001 From: hf_trixie Date: Sat, 15 Aug 2026 05:32:50 +0200 Subject: 添加Arch系安装方法,隔离使用 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/applications/programming/python.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'docs/applications/programming/python.md') diff --git a/docs/applications/programming/python.md b/docs/applications/programming/python.md index bbc0af9..a6b3233 100644 --- a/docs/applications/programming/python.md +++ b/docs/applications/programming/python.md @@ -4,7 +4,14 @@ ### 安装 -无须安装,发行版自带。 +除个别极简发行版外(如Arch),大多数发行版已自带。 + +Arch系: +```bash +sudo pacman -S python +``` + +### 使用 Linux里面一般以`python3`命令使用Python。 -- cgit v1.3 From 98073d6c2673663a1c04efda8295b7c3def821ab Mon Sep 17 00:00:00 2001 From: at2er Date: Sat, 15 Aug 2026 11:56:31 +0800 Subject: feat(python.md): 'python-is-python3' --- docs/applications/programming/python.md | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'docs/applications/programming/python.md') diff --git a/docs/applications/programming/python.md b/docs/applications/programming/python.md index a6b3233..6629a08 100644 --- a/docs/applications/programming/python.md +++ b/docs/applications/programming/python.md @@ -15,3 +15,8 @@ sudo pacman -S python Linux里面一般以`python3`命令使用Python。 +???+ tip "通过`python`使用" + 如果你想要用 `python` 这个命令, 可以装一个 `python-is-python3`, 来用软链接骗过操作系统(开个玩笑)。 + + - Debian: `sudo apt install python-is-python3 -y` + - Fedora: `sudo dnf install python-is-python3 -y` -- cgit v1.3 From c9a2942ac34e94ee873ed57e29e011a67bc3d9c4 Mon Sep 17 00:00:00 2001 From: at2er Date: Sat, 15 Aug 2026 14:13:38 +0800 Subject: revert(python): library --- docs/applications/programming/python.md | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'docs/applications/programming/python.md') diff --git a/docs/applications/programming/python.md b/docs/applications/programming/python.md index 6629a08..29ad315 100644 --- a/docs/applications/programming/python.md +++ b/docs/applications/programming/python.md @@ -20,3 +20,37 @@ Linux里面一般以`python3`命令使用Python。 - Debian: `sudo apt install python-is-python3 -y` - Fedora: `sudo dnf install python-is-python3 -y` + +## 库 + +Python拥有规模庞大的PyPi库。通常,我们使用`pip`进行安装。但在Linux下,`pip`不一定会随着Python预装,因此需要使用包管理器安装。 + +- Debian: `sudo apt install python3-pip` +- Fedora: `sudo dnf install python3-pip` +- Arch: `sudo pacman -S python-pip` + +!!! warning "系统依赖" + 使用Pip安装部分库时,可能会出现如下警告: + ``` + error: externally-managed-environment + + × This environment is externally managed + ╰─> To install Python packages system-wide, try 'pacman -S + python-xyz', where xyz is the package you are trying to + install. + + If you wish to install a non-Arch-packaged Python package, + create a virtual environment using 'python -m venv path/to/venv'. + Then use path/to/venv/bin/python and path/to/venv/bin/pip. + + If you wish to install a non-Arch packaged Python application, + it may be easiest to use 'pipx install xyz', which will manage a + virtual environment for you. Make sure you have python-pipx + installed via pacman. + + note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. + hint: See PEP 668 for the detailed specification. + ``` + 由于系统的部分组件依赖Python的依赖,因而外来库可能破坏系统本身的依赖关系。 + + 这个时候,我们建议您使用`venv`创建虚拟环境,或者寻找发行版的软件源是否有对应的库可供安装(一般包名为`python3-库`或`python-库`)。 -- cgit v1.3