我正试图通过bash脚本激活我的conda env.即使脚本运行正常并且我的PATH似乎在脚本中被更改,它也会在脚本终止后以某种方式重置.我可以从cmd行调用source activate test,它工作正常.下面的输出示例.
脚本:
PycharmProjects / test»cat ./example.sh
echo“在调用source之前:$PATH”
源激活测试
echo“在调用source:$PATH之后”
输出:
./example.sh before calling source: /Use rs/me/miniconda3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin discarding /Users/me/miniconda3/bin from PATH prepending /Users/me/miniconda3/envs/test/bin to PATH after calling source: /Users/me/miniconda3/envs/test/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin`
但如果我在脚本完成后回显$PATH,你可以看到$PATH没有改变(即没有/ Users / me / miniconda3 / envs / test / bin):
PycharmProjects / test»echo $PATH / Users / me / miniconda3 / bin:/usr/local / bin:/usr/local / sbin:/usr/bin:/ bin:/usr/sbin:/ sbin:/ Library / TeX / texbin