系统:Ubuntu16.04

[1] - 查看环境变量

echo $PATH
echo $PYTHONPATH

[2] - 修改用户目录中 /home/username/.bashrc 添加环境变量(对当前用户username生效(永久)). 运行 source ~/.bashrc 立即生效.

vim ~/.bashrc
source ~/.bashrc

[3] - 修改 /etc/profile,添加环境变量(对所有用户生效(永久)). 运行 source /etc/profile 立即生效.

sudo vim /etc/profile
source /etc/profile

[4] - 终端运行 export 命令 export 变量名=变量值,添加环境变量(只对当前 shell 生效(临时)). 关闭该终端后,则环境变量失效. 如:

export PATH=/usr/local/cuda-9.0/bin:$PATH
export PYTHONPATH=$PYTHONPATH:/data/tensorflow/models/research:/data/tensorflow/models/research/slim
Last modification:October 18th, 2020 at 10:16 am