Linux上运行 Python3

各大Linux发行版都自带python,这里简单介绍Ubuntu 22.04(24.04)运行 python3.

也可以自己安装升级:

  1. 安装(此步骤可以省略) 在终端中输入以下命令来安装 Python:
sudo apt update
sudo apt install python3

  1. 安装 pip(Python 包管理工具) 安装 pip 以便于安装和管理 Python 包:
sudo apt install python3-pip
  1. 使用pip3 安装python库,例如安装numpy
pip3 install numpy
  1. 测试numpy是否安装成功
chenlongos@chenlongos-LAPKC71E:~$ python3
Python 3.12.3 (main, Jul 31 2024, 17:43:48) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> 

  1. 运行一个python文件
python3 hello.py