bash - 无法弄清楚我如何在 Ubuntu 中设置我的 PYTHONPATH

标签 bash ubuntu pythonpath

一旦我 ssh 进入我的 ubuntu,我的 PYTHONPATH 就会显示

:/usr/local/opencv-2.4.13/build/modules/python:/usr/local/mxnet/python:/usr/local/caffe/python

我不想要这些起始设置,但我不知道它们是如何设置的。它们未在 .bashrc 或 .profile 中设置。我还应该去哪里看?

最佳答案

要检查的位置列表(这包括这些文件中的任何一个源或运行的脚本,这意味着在此文件列表中为有问题的变量提供 grep 是不够的):

/etc/profile

文件夹 /etc/profile.d/ 中的所有文件
/etc/environment
~/.bash_profile, ~/.bash_login, and ~/.profile 的第一个现有文件
/etc/bash.bashrc (or /etc/bashrc , depending on OS)
~/.bashrc
~/.pam_environment (when using ssh)
/etc/motd (when using ssh)

解释:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.



When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. This may be inhibited by using the --norc option.



The contents of /etc/motd are displayed by pam_motd(8) after a successful login but just before it executes the login shell. The abbreviation "motd" stands for "message of the day", and this file has been traditionally used for exactly that (it requires much less disk space than mail to all users). On Debian GNU/Linux, the content of /run/motd.dynamic is also displayed. This file is generated by /etc/init.d/motd at boot.

关于bash - 无法弄清楚我如何在 Ubuntu 中设置我的 PYTHONPATH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51601059/

相关文章:

bash - 如何在不产生两个进程的情况下以不同的用户身份运行 nohup?

linux - 使用 tr 命令在 bash shell 脚本中将字母转换为数字

PYTHONPATH 不适用于多个路径

python - 为开发环境管理 PYTHONPATH

bash - 需要使用 sed 更改 json 文件的值

bash:读取行并保留空格

ruby - 如何使 Ruby 1.9 成为 Ubuntu 上的默认 Ruby?

ubuntu - VS Code 连接到 WSL Ubuntu 20.04 LTS,失败并出现错误 : Could not fetch remote environment

ubuntu - Ubuntu Virtualbox 中 Pycharm 中的 Python 控制台无法连接

python - 设置pythonpath的正确方法