問題闡述
如下圖,user內安裝了python3.7,且配置好了環境。
切換到root,再python內找不到python3.7的版本,因此也就無法使用配置好的環境。
目的:使root可以調用python3.7(user的python)
解決
這篇博客給了我很大啓發。
update-alternatives --list python
得到系統python路徑,但是並沒有user python3.7的路徑(見上圖)
alternatives --install /home/user/bin/python3 python /home/user/bin/python3 3
出現瞭如下錯誤:
update-alternatives: <link> and <path> can't be the same
發現原來兩個路徑不能一樣
改成
alternatives --install /usr/bin/python3.7 python /home/user/bin/python3 3
解決問題