Python模块搜索路径设置 Python环境变量设置

来源:互联网 发布:qq群关系数据库 种子 编辑:程序博客网 时间:2024/05/17 14:21

验证失败




Ubuntu add directory to Python pathhttp://stackoverflow.com/questions/16913086/ubuntu-add-directory-to-python-path 


Create a .bash_profile in your home directory. Then, add the line

PYTHONPATH=$PYTHONPATH:new_dirEXPORT $PYTHONPATH

Or even better:

if [ -d "new_dir" ] ; then  PYTHONPATH="$PYTHONPATH:new_dir"fiEXPORT $PYTHONPATH

The .bash_profile properties are loaded every time you log in.

The source command is useful if you don't want to log in again.


附:

What's the difference between .bashrc, .bash_profile, and .environment?

http://stackoverflow.com/questions/415403/whats-the-difference-between-bashrc-bash-profile-and-environment

The main difference with shell config files is that some are only read by "login" shells (eg. when you login from another host, or login at the text console of a local unix machine). these are the ones called, say,.login or.profile or .zlogin (depending on which shell you're using).

Then you have config files that are read by "interactive" shells (as in, ones connected to a terminal (or pseudo-terminal in the case of, say, a terminal emulator running under a windowing system). these are the ones with names like.bashrc,.tcshrc,.zshrc, etc.

bash complicates this in that .bashrc is only read by a shell that's bothinteractive andnon-login, so you'll find most people end up telling their.bash_profile to also read.bashrc with something like

[[ -r ~/.bashrc ]] && . ~/.bashrc

Other shells behave differently - eg with zsh, .zshrc is always read for an interactive shell, whether it's a login one or not.

The manual page for bash explains the circumstances under which each file is read. Yes, behaviour is generally consistent between machines.

.profile is simply the login script filename originally used by /bin/sh. bash, being generally backwards-compatible with /bin/sh, will read .profile if one exists.


FILES       /bin/bash              The bash executable       /etc/profile              The systemwide initialization file, executed for login shells       /etc/bash.bashrc              The systemwide per-interactive-shell startup file       /etc/bash.bash.logout              The systemwide login shell cleanup file, executed when  a  login              shell exits       ~/.bash_profile              The personal initialization file, executed for login shells       ~/.bashrc              The individual per-interactive-shell startup file       ~/.bash_logout              The  individual  login shell cleanup file, executed when a login              shell exits       ~/.inputrc              Individual readline initialization file




0 0
原创粉丝点击