linux安装python
默认centos, unbtan都已经安装了python3版本,可以通过 whereis python来检查已经安装的版本。
root@hecs-x-medium-2-linux-20200619090653:/usr/bin# whereis python
python: /usr/bin/python3.8 /usr/bin/python3.8-config /usr/bin/python /usr/lib/python3.9 /usr/lib/python2.7 /usr/lib/python3.8 /etc/python3.8 /usr/local/lib/python3.8 /usr/include/python3.8
root@hecs-x-medium-2-linux-20200619090653:/usr/bin# whereis python3
python3: /usr/bin/python3.8 /usr/bin/python3.8-config /usr/bin/python3 /usr/lib/python3.9 /usr/lib/python3.8 /usr/lib/python3 /etc/python3.8 /etc/python3 /usr/local/lib/python3.8 /usr/include/python3.8 /usr/share/python3 /usr/share/man/man1/python3.1.gz
root@hecs-x-medium-2-linux-20200619090653:/usr/bin#
如果没有python的命令,可以通过修改和增加链接文件的方式来实现。
root@hecs-x-medium-2-linux-20200619090653:/usr/bin# cd /usr/bin/
root@hecs-x-medium-2-linux-20200619090653:/usr/bin# ls -l py*
-rwxr-xr-x 1 root root 7813 Mar 13 2020 py3clean
-rwxr-xr-x 1 root root 12120 Mar 13 2020 py3compile
lrwxrwxrwx 1 root root 31 Dec 12 17:23 py3versions -> ../share/python3/py3versions.py
lrwxrwxrwx 1 root root 8 Dec 12 17:23 pydoc3 -> pydoc3.8
-rwxr-xr-x 1 root root 79 Jul 28 2020 pydoc3.8
lrwxrwxrwx 1 root root 12 Dec 12 17:23 pygettext3 -> pygettext3.8
-rwxr-xr-x 1 root root 21535 Jul 28 2020 pygettext3.8
-rwxr-xr-x 1 root root 392 Apr 2 2020 pyhtmlizer3
-rwxr-xr-x 1 root root 372 Apr 6 2020 pyjwt3
lrwxrwxrwx 1 root root 11 Feb 6 21:19 python -> ./python3.8
lrwxrwxrwx 1 root root 9 Dec 12 17:23 python3 -> python3.8
-rwxr-xr-x 1 root root 5486352 Jul 28 2020 python3.8
lrwxrwxrwx 1 root root 33 Jul 28 2020 python3.8-config -> x86_64-linux-gnu-python3.8-config
lrwxrwxrwx 1 root root 16 Mar 13 2020 python3-config -> python3.8-config
如果没有安装,就用apt install python, apt install python3来安装
root@hecs-x-medium-2-linux-20200619090653:/usr/bin# apt install python
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'python-is-python2' instead of 'python'
The following additional packages will be installed:
libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib python2 python2-minimal python2.7 python2.7-minimal
Suggested packages:
python2-doc python-tk python2.7-doc binfmt-support
The following NEW packages will be installed:
libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib python-is-python2 python2 python2-minimal python2.7 python2.7-minimal
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,803 kB of archives.
After this operation, 16.4 MB of additional disk space will be used.
Do you want to continue? [Y/n]
root@hecs-x-medium-2-linux-20200619090653:/usr/bin# apt install python3
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3 is already the newest version (3.8.2-0ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· 因为Apifox不支持离线,我果断选择了Apipost!