简体   繁体   English

当我没有.bash_profile时,python路径设置在哪里?

[英]Where is the python path set when I don't have a .bash_profile?

I am running ubuntu, and I don't have a .bash_profile. 我正在运行ubuntu,而且我没有.bash_profile。

So my question is, where exactly is my python path set then? 所以我的问题是,我的python路径到底在哪里?

How can I see what the current python path is, doing: 如何查看当前的python路径:

$PYTHON_PATH

doesn't return anything? 不归还什么?

It's set by the site module, and the interpreter executable itself. 它由site模块和解释器可执行文件本身设置。 sys.path contains the current value. sys.path包含当前值。

You can see your python path in python like so: 你可以在python中看到你的python路径,如下所示:

>> import sys
>> print sys.path

you can create a .bash_profile with your favorite editor, and put into it: 你可以用自己喜欢的编辑器创建一个.bash_profile,然后输入:

export PYTHONPATH=$HOME/lib/python

or whatever, that's one example. 或者其他什么,这是一个例子。

echo $PYTHONPATH /etc/profile and /etc/bashrc are the global setting files bash scans before looking in your home directory at start up. echo $PYTHONPATH / etc / profile和/ etc / bashrc是全局设置文件bash扫描,然后在启动时查看主目录。 It's also safe to create a .bash_profile if one doesn't exist. 如果不存在,创建.bash_profile也是安全的。

Normally PYTHONPATH is empty anyways. 通常情况下,PYTHONPATH是空的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM