$ which jupyter
/home/tgowda/miniconda3/envs/unsup/bin/jupyter
$ head -1 $(which jupyter) # its hashbang is still looking at old
#!/home/tgowda/miniconda3/envs/rtg/bin/python
因此,我们可以很容易地用sed来修复它
$ sed -i.bak "s:envs/$OLD/bin:envs/$NEW/bin:" $NEW/bin/*
# `-i.bak` created backups, to be safe
$ head -1 $(which jupyter) # check if updated
#!/home/tgowda/miniconda3/envs/unsup/bin/python
$ jupyter --version # check if it works
jupyter core : 4.6.3
jupyter-notebook : 6.0.3
$ rm $NEW/bin/*.bak # remove backups
现在我们完成了💯
我认为编写一个可移植脚本来完成所有这些并将其绑定到conda env rename old new应该是很简单的。
我在ubuntu上进行了测试。由于任何不可预见的原因,如果出现故障,您希望恢复上述更改:
$ mv $NEW $OLD
$ sed -i.bak "s:envs/$NEW/bin:envs/$OLD/bin:" $OLD/bin/*