我如何知道 linux ubuntu 上的 python 路径?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20424111/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 20:23:57  来源:igfitidea点击:

How do i know python path on linux ubuntu?

pythonpython-2.7ubuntu-12.04

提问by Mero

In ubuntu linux if we want to set up python path we do something like this:

在 ubuntu linux 中,如果我们想设置 python 路径,我们可以这样做:

export PYTHONPATH=/etc ...

导出 PYTHONPATH=/etc ...

Now, how i would know what the current path I have?

现在,我怎么知道我当前的路径是什么?

采纳答案by aquavitae

First, I hope you don't really set PYTHONPATH=/etc, /etcis for configuration files, not python libraries.

首先,我希望你没有真正设置PYTHONPATH=/etc/etc是用于配置文件,而不是python库。

You can see what an environment variable is set to by using echo, e.g.: echo $PYTHONPATH. If the variable has not been set it will be blank. You can also use envto get a list of all environment variables, and couple with grepto see if a particular one is set, e.g. env | grep PYTHONPATH.

您可以使用echo,例如:来查看环境变量的设置echo $PYTHONPATH。如果变量尚未设置,它将为空。您还可以使用env获取所有环境变量的列表,并结合grep查看是否设置了特定的环境变量,例如env | grep PYTHONPATH.

回答by hmd.ai

use printenv command, it will print all the environment variables, to only print PYTHONPATH use: printenv PYTHONPATH

使用 printenv 命令,它将打印所有环境变量,仅打印 PYTHONPATH 使用:printenv PYTHONPATH

回答by Aashish Ranjan

You can type which pythonon the ubuntu terminal and it will give the Python installed location path.

您可以在 ubuntu 终端上输入which python,它会给出 Python 安装的位置路径。