当前位置:   article > 正文

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

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

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

  1. yww@yww:~/test$ python test.py
  2. Command 'python' not found, did you mean:
  3. command 'python3' from deb python3
  4. 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

安装过程如下:

  1. yww@yww:~/test$ sudo apt install python-is-python3
  2. Reading package lists... Done
  3. Building dependency tree... Done
  4. Reading state information... Done
  5. The following NEW packages will be installed:
  6. python-is-python3
  7. 0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
  8. Need to get 2,788 B of archives.
  9. After this operation, 13.3 kB of additional disk space will be used.
  10. Get:1 https://mirror.nju.edu.cn/ubuntu jammy/main amd64 python-is-python3 all 3.9.2-2 [2,788 B]
  11. Fetched 2,788 B in 11s (264 B/s)
  12. Selecting previously unselected package python-is-python3.
  13. (Reading database ... 220473 files and directories currently installed.)
  14. Preparing to unpack .../python-is-python3_3.9.2-2_all.deb ...
  15. Unpacking python-is-python3 (3.9.2-2) ...
  16. Setting up python-is-python3 (3.9.2-2) ...
  17. Processing triggers for man-db (2.10.2-1) ...
  18. yww@yww:~/test$ python test.py
  19. hello yww
  20. hello world
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/65279
推荐阅读
相关标签
  

闽ICP备14008679号