国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > Python > 正文

更改Ubuntu默認(rèn)python版本的兩種方法python-> Anaconda

2019-11-25 16:26:40
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

你可以按照以下方法使用 ls 命令來(lái)查看你的系統(tǒng)中都有那些 Python 的二進(jìn)制文件可供使用。

$ ls /usr/bin/python*/usr/bin/python /usr/bin/python2 /usr/bin/python2.7 /usr/bin/python3 /usr/bin/python3.4 /usr/bin/python3.4m /usr/bin/python3m

執(zhí)行如下命令查看默認(rèn)的 Python 版本信息:

$ python --versionPython 2.7.8

1、基于用戶修改 Python 版本:

想要為某個(gè)特定用戶修改 Python 版本,只需要在其 home 目錄下創(chuàng)建一個(gè) alias(別名) 即可。打開(kāi)該用戶的 ~/.bashrc文件,添加新的別名信息來(lái)修改默認(rèn)使用的 Python 版本。

alias python='/usr/bin/python3.4'

一旦完成以上操作,重新登錄或者重新加載 .bashrc 文件,使操作生效。

$ . ~/.bashrc

檢查當(dāng)前的 Python 版本。

$ python --versionPython 3.4.2

2、 在系統(tǒng)級(jí)修改 Python 版本

我們可以使用 update-alternatives 來(lái)為整個(gè)系統(tǒng)更改 Python 版本。以 root 身份登錄,首先羅列出所有可用的 python 替代版本信息:

# update-alternatives --list pythonupdate-alternatives: error: no alternatives for python

如果出現(xiàn)以上所示的錯(cuò)誤信息,則表示 Python 的替代版本尚未被 update-alternatives 命令識(shí)別。想解決這個(gè)問(wèn)題,我們需要更新一下替代列表,將 python2.7 和 python3.4 放入其中。

# update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode# update-alternatives --install /usr/bin/python python /usr/bin/python3.4 2update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode

--install 選項(xiàng)使用了多個(gè)參數(shù)用于創(chuàng)建符號(hào)鏈接。最后一個(gè)參數(shù)指定了此選項(xiàng)的優(yōu)先級(jí),如果我們沒(méi)有手動(dòng)來(lái)設(shè)置替代選項(xiàng),那么具有最高優(yōu)先級(jí)的選項(xiàng)就會(huì)被選中。這個(gè)例子中,我們?yōu)?/usr/bin/python3.4 設(shè)置的優(yōu)先級(jí)為2,所以u(píng)pdate-alternatives 命令會(huì)自動(dòng)將它設(shè)置為默認(rèn) Python 版本。

# python --versionPython 3.4.2

接下來(lái),我們?cè)俅瘟谐隹捎玫?Python 替代版本。

# update-alternatives --list python/usr/bin/python2.7/usr/bin/python3.4

現(xiàn)在開(kāi)始,我們就可以使用下方的命令隨時(shí)在列出的 Python 替代版本中任意切換了。

# update-alternatives --config python

# python --versionPython 2.7.8

3、移除替代版本

一旦我們的系統(tǒng)中不再存在某個(gè) Python 的替代版本時(shí),我們可以將其從 update-alternatives 列表中刪除掉。例如,我們可以將列表中的 python2.7 版本移除掉。

# update-alternatives --remove python /usr/bin/python2.7update-alternatives: removing manually selected alternative - switching python to auto modeupdate-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode

方法2、移除軟連接

rm -rf /data/logsln -s /temp/logs /data/logs

解決軟連接ln報(bào)錯(cuò)-bash: /usr/local/bin/mysql: Too many levels of symbolic links

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,如果有疑問(wèn)大家可以留言交流。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 宁乡县| 惠来县| 雷州市| 卓资县| 邵东县| 镇江市| 鱼台县| 砀山县| 易门县| 筠连县| 霍城县| 句容市| 海城市| 广德县| 长垣县| 怀来县| 区。| 边坝县| 弥渡县| 永胜县| 浙江省| 筠连县| 元氏县| 光泽县| 乌审旗| 兰溪市| 江北区| 东台市| 遂平县| 察雅县| 若尔盖县| 临夏市| 鄂尔多斯市| 平昌县| 丰顺县| 吴江市| 黄平县| 岳池县| 怀集县| 郎溪县| 涿州市|