Ubuntu:找不到Python命令,但apt表示已经安装

时间:2019-01-21 23:21:17

标签: python ubuntu

我在Ubuntu上,需要运行python脚本,但是bash找不到python。

$ python main.py
bash: python: command not found

当我使用apt安装它时,会被告知它已经安装。

$ sudo apt-get install python
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python is already the newest version (2.7.12-1~16.04).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

我该如何解决?

2 个答案:

答案 0 :(得分:2)

尝试使用命令which python,它将显示系统安装Python的位置。

然后尝试将which python显示的位置添加到PYTHONPATH作为第一个答案here。这是了解这一点的好地方。

答案 1 :(得分:0)

它另存为python3而不是python

相关问题