ubuntu服務器 root使用user的python版本

ubuntu服務器 root使用用戶(user)的python版本

問題闡述

如下圖,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

解決問題

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章