开发者社区> 问答> 正文

Ubuntu:找不到Python命令,但apt说已经安装了

我在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.

展开
收起
一码平川MACHEL 2019-01-22 17:01:05 13317 0
4 条回答
写回答
取消 提交回答
  • main.py

    中第一行指定解释器

    #!/usr/bin python

    2019-11-22 11:39:24
    赞同 展开评论 打赏
  • 1、python已经被安装在电脑里,但是没有在bin里关联全局指令;
    2、解决办法上面都说啦,其实根本的做法就是找到python的原始目录;

    2019-07-17 23:26:21
    赞同 展开评论 打赏
  • 如上所述,可以用which命令看python的位置,然后用“echo $PATH”查看系统执行目录是否包含python解释器所在目录。

    2019-07-17 23:26:21
    赞同 展开评论 打赏
  • 尝试该命令which python,它将显示系统安装Python的位置。

    然后尝试将显示的位置添加which python到此处PYTHONPATH作为第一个答案。

    2019-07-17 23:26:21
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载