我通常倾向于使用有用的命令来记录某些会话script
。但是,我观察到,使用它时行为似乎发生了变化。确切地说,
使用之前script
,python的位置如下
$ which python
/home/abhishek/Softwares/anaconda3/bin/python
而在应用时script
,它会变为
$ which python
/home/abhishek/Softwares/miniconda2/bin/python
我怀疑这是由于添加到环境变量中的 Python 主目录的顺序不同,PATH
我确认如下。
前 script
$ echo $PATH
/home/abhishek/Softwares/anaconda3/bin:/home/abhishek/Softwares/anaconda3/condabin:/home/abhishek/Softwares/miniconda2/bin:/home/abhishek/Softwares/wkhtmltox/bin:/home/abhishek/Softwares/cuda-8.0/bin:/home/abhishek/Softwares/asymptote-2.41/installation_dir/bin:/home/abhishek/bin:/home/abhishek/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/abhishek/.dotnet/tools:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
后 script
$ echo $PATH
/home/abhishek/Softwares/miniconda2/bin:/home/abhishek/Softwares/wkhtmltox/bin:/home/abhishek/Softwares/cuda-8.0/bin:/home/abhishek/Softwares/anaconda3/bin:/home/abhishek/Softwares/anaconda3/condabin:/home/abhishek/Softwares/miniconda2/bin:/home/abhishek/Softwares/wkhtmltox/bin:/home/abhishek/Softwares/cuda-8.0/bin:/home/abhishek/Softwares/asymptote-2.41/installation_dir/bin:/home/abhishek/bin:/home/abhishek/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/abhishek/.dotnet/tools:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
我尝试通过观察来理解$PATH
内部是如何设置的script
其中 $PATH 设置/etc/environment
总的来说。从那以后,我检查了(似乎最相关的)内容
$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
但不确定上述变量是如何设置的机制。
因此,为了确保选择了预期的python安装,我想知道如何$PATH
在内部重置script