Command ‘python‘ not found, did you mean: command ‘python3‘ from deb python3

如果在Ubuntu中已经安装python3,但是执行的时候,会出现如下错误:

yww@yww:~/test$ python test.py
Command 'python' not found, did you mean:
  command 'python3' from deb python3
  command 'python' from deb python-is-python3

如果不确定是否安装python,可以通过在终端中输入以下命令

python3 --version

查看是否安装,如果没有安装python,需要通过如下命令安装python

sudo apt install python3

如果确定已经安装python,有两种方法可以运行py文件

  1. 通过python3运行

python3 test.py
  1. 将python命令映射到python,需要安装软件包`python-is-python3`:

sudo apt install python-is-python3

安装过程如下:

yww@yww:~/test$ sudo apt install python-is-python3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  python-is-python3
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 2,788 B of archives.
After this operation, 13.3 kB of additional disk space will be used.
Get:1 https://mirror.nju.edu.cn/ubuntu jammy/main amd64 python-is-python3 all 3.9.2-2 [2,788 B]
Fetched 2,788 B in 11s (264 B/s)              
Selecting previously unselected package python-is-python3.
(Reading database ... 220473 files and directories currently installed.)
Preparing to unpack .../python-is-python3_3.9.2-2_all.deb ...
Unpacking python-is-python3 (3.9.2-2) ...
Setting up python-is-python3 (3.9.2-2) ...
Processing triggers for man-db (2.10.2-1) ...
yww@yww:~/test$ python test.py
hello yww
hello world
  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ywwsnowboy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值