在 Linux 系统中,使用 'whereis python' 命令可能会显示 Python 2.7 的执行路径,而 'python3' 命令却可以正常使用。这是因为系统可能同时安装了 Python 2 和 Python 3,而 'whereis' 命令可能只找到了 Python 2 的安装路径。

要查看 Python 3 的执行路径,可以使用 'which python3' 命令。如果 'which' 命令没有安装,可以使用 'sudo apt-get install which' 命令进行安装。

如果 'which' 命令也无法找到 Python 3 的执行路径,可以尝试以下方法:

  1. 重新安装 Python 3:

    您可以使用包管理器重新安装 Python 3,例如:

    sudo apt-get update
    sudo apt-get install python3
    
  2. 添加 Python 3 的执行路径到系统环境变量中:

    您可以将 Python 3 的执行路径添加到系统环境变量中,例如:

    export PATH=$PATH:/usr/bin/python3.8
    

    其中,'/usr/bin/python3.8' 是 Python 3 的执行路径。您需要根据实际情况修改路径。

完成以上操作后,再次使用 'whereis python' 命令,应该就可以找到 Python 3 的执行路径了。

解决'whereis python' 只显示 Python 2.7 路径,而 'python3' 可用问题

原文地址: https://www.cveoy.top/t/topic/jlMT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录