zoukankan      html  css  js  c++  java
  • 运维笔记--linux环境提示python: command not found

    场景描述:

    新部署的容器环境,终端执行python命令,提示没有该命令。

    从报错异常可以看出,可能是python环境未安装。

    分析思路:

    检查python路径:

    方式一:type -a python

    方式二:

    ls -l /usr/bin/python
    ls -l /usr/bin/python*

    方式三:

    which python

    如果输出空或者no such file or directory, 则说明未安装。

    处理过程:

    不同Linux系统版本安装方式不同!

    Ubuntu/Debian/Mint Linux install Python

    安装python2

    $ sudo apt-get install python

    安装python3

    $ sudo apt-get install python3

    Oracle/RHEL (Red Hat)/CentOS Linux install Python

    $ sudo yum install python

    Fedora Linux install Python

    python2: $ sudo dnf install python

    python3: $ sudo dnf install python3

    MacOS X Unix install Python3

    Type the following command:
    $ brew install python3

    Arch Linux install Python

    python2: $ sudo pacman -S python2

    python3:$ sudo pacman -S python3

    FreeBSD Unix install Python

    Type the following pkg command to add the Python v2.x:
    # pkg install python2
    OR To install the Python v2.x port:
    # cd /usr/ports/lang/python2/ && make install clean
    To add the Python v3.x package:
    # pkg install python3
    OR To install the Python v3.x port:
    # cd /usr/ports/lang/python3/ && make install clean

    OpenBSD Unix install Python

    Type the following pkg_add command to add the Python v2.x or 3.x:
    # pkg_add python
    OR
    $ doas pkg_add python

    如果需要创建软链接:

    A note about broken symlink

    Sometimes a soft link to Pythons’s executables is broken for some reason. For example, /usr/bin/python3.4 is real executables. You can point /usr/bin/python to /usr/bin/python3.4 for Python version 3.4 using the ln command:
    $ sudo ln -s /usr/bin/python3.4 /usr/bin/python
    Now you can run program:
    $ python mycode.py

    参考:https://www.cyberciti.biz/faq/bash-python-command-not-found/

  • 相关阅读:
    jquery通过val()取不到textarea中的值
    form表单右边弹窗提示不能为空
    正则表达式
    layui表格的批量删除功能
    layui中table表格的操作列(删除,编辑)等按钮的操作
    layui动态渲染生成select的option值
    layui实现table表格的“关键字搜索”功能
    Python3基础 break while循环示例
    Python3基础 bool类型变量赋值
    Python3基础 assert 断言 确保程序的正确运行条件
  • 原文地址:https://www.cnblogs.com/hellojesson/p/10825071.html
Copyright © 2011-2022 走看看