【问题标题】:How do I add Python to PATH?如何将 Python 添加到 PATH?
【发布时间】:2019-10-31 21:47:28
【问题描述】:

我有以下

ubuntu@ip:/$ whereis python
python: /usr/bin/python3.7 /usr/bin/python3.7m /usr/bin/python3.6m /usr/bin/python3.6 /usr/lib/python2.7 /usr/lib/python3.7 /usr/lib/python3.6 /etc/python3.7 /etc/python3.6 /usr/local/lib/python3.7 /usr/local/lib/python3.6 /usr/share/python
ubuntu@ip:/$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3       
sudo apt install python        
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.

如何设置 Python,以便我可以在终端中调用 python,以便其他程序可以使用它??

谢谢

【问题讨论】:

  • 你想用哪一条蟒蛇?
  • @martineau 我想用 3.6
  • 您必须使用 export 以及 Python 3.6 目录的路径。见How to set your $PATH variable in Linux
  • @martineau 我确实 export PATH=$PATH:/usr/bin/python3.6 但它仍然抱怨找不到python...
  • 如果您希望在键入python 时运行 3.6 文件夹中的 python 解释器,那么您需要创建一个别名,如 @Muni 的回答中所述 - 否则我认为您可以运行它通过显式输入python3

标签: python linux path


【解决方案1】:

您可以将 Python3 作为默认 python 写入 bash 别名。

参考这篇文章:Configure Python 3 as default on Ubuntu

【讨论】:

    猜你喜欢
    • 2020-09-01
    • 1970-01-01
    • 2016-06-17
    • 1970-01-01
    • 2011-09-13
    • 1970-01-01
    • 2018-02-21
    • 1970-01-01
    相关资源
    最近更新 更多