久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Ubuntu上安裝和使用Python3.6的方法是什么

202次閱讀
沒有評論

共計 3019 個字符,預(yù)計需要花費 8 分鐘才能閱讀完成。

這篇文章主要介紹了 Ubuntu 上安裝和使用 Python3.6 的方法是什么的相關(guān)知識,內(nèi)容詳細易懂,操作簡單快捷,具有一定借鑒價值,相信大家閱讀完這篇 Ubuntu 上安裝和使用 Python3.6 的方法是什么文章都會有所收獲,下面我們一起來看看吧。

錯誤如下:

david@KingChef-Workstation:~/learnpy$ python3 ex5.pyFile  ex5.py , line 9print(f Let s talk about {my_name}. )^SyntaxError: invalid syntax

再三檢查發(fā)現(xiàn)代碼沒有問題,但運行就是出錯。聽說 Python 各版本之間會有差異,會不會是因為 Python 版本本身的問題呢?

david@KingChef-Workstation:~$ python -VPython 2.7.12david@KingChef-Workstation:~$ python3 -VPython 3.5.2

Ubuntu 16.04 默認安裝的 Python 版本是 2.7 和 3.5,而  Learn Python 3 The Hard Way  里面用的是 Python 3.6。需要安裝 Python 3.6 了,好在 Ubuntu 下面可以很方便的讓多個 Python 版本同時存在,只要在運行的時候指定 Python 的版本號就可以了。要在 Ubuntu 16.04 上面安裝 Python 3.6 需要添加 python 3.6 的源:

david@KingChef-Workstation:~$ sudo add-apt-repository ppa:jonathonf/python-3.6[sudo] password for david:A plain backport of *just* Python 3.6. System extensions/Python libraries may or may not work.Don t remove Python 3.5 from your system - it will break.More info: https://launchpad.net/~jonathonf/+archive/ubuntu/python-3.6Press [ENTER] to continue or ctrl-c to cancel adding it

這里提示我們安裝 Python 3.6 后不要刪除 Python 3.5,不然的話系統(tǒng)會崩潰,因為 Linux 系統(tǒng)里面對 Pyhon 的依賴是比較多的,網(wǎng)上能查到很多人吐槽自己刪除系統(tǒng)默認的 Python 版本后出現(xiàn)問題,不得不重新裝回原來的版本,甚至重裝系統(tǒng)的經(jīng)歷。我們根據(jù)提示鍵入 Enter 后,把 Python 3.6 的 PPA 源正式加入到源列表:

gpg: keyring `/tmp/tmpsnw0vrl9/secring.gpg  created
gpg: keyring `/tmp/tmpsnw0vrl9/pubring.gpg  created
gpg: requesting key F06FC659 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpsnw0vrl9/trustdb.gpg: trustdb created
gpg: key F06FC659: public key  Launchpad PPA for J Fernyhough  imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK

確認無誤后,運行 apt update 更新資源列表,然后安裝 Python 3.6:

$ sudo apt update$ sudo apt install python3.6Reading package lists... DoneBuilding dependency treeReading state information... DoneThe following additional packages will be installed:libpython3.6-minimal libpython3.6-stdlib python3.6-minimalSuggested packages:python3.6-venv python3.6-docThe following NEW packages will be installed:libpython3.6-minimal libpython3.6-stdlib python3.6 python3.6-minimal0 upgraded, 4 newly installed, 0 to remove and 1 not upgraded.Need to get 4,505 kB of archives.After this operation, 23.1 MB of additional disk space will be used.Do you want to continue? [Y/n]

因為源文件在國外,下載軟件的過程可能會超時,如果出錯,可以重新運行安裝命令直到安裝完成。完成后可以通過查看 Python 版本來確認是否能夠安裝成功:

$ python -VPython 2.7.12$ python3 -VPython 3.5.2$ python3.5 -VPython 3.5.2$ python3.6 -VPython 3.6.5

幾個命令下來我們看到,默認的版本還是 2.7,Python3 的默認版本還是 3.5.2,如果要用 Python 3.6 運行.py 腳本的話,需要直接指定 Python 版本:

~/learnpy$ python3 ex5.pyFile  ex5.py , line 9print(f Let s talk about {my_name}. )^SyntaxError: invalid syntax~/learnpy$ python3.6 ex5.pyLet s talk about David Wei.He s 170cm tall.He s 68kg heavy.Actually that s not too heavy.He s got Black eyes and Black hair.His teeth are usually White depending on the coffee.If I add 36, 170, and 68 I get 274.

python 主要應(yīng)用領(lǐng)域有哪些

1、云計算,典型應(yīng)用 OpenStack。

2、WEB 前端開發(fā),眾多大型網(wǎng)站均為 Python 開發(fā)。

3、人工智能應(yīng)用,基于大數(shù)據(jù)分析和深度學(xué)習(xí)而發(fā)展出來的人工智能本質(zhì)上已經(jīng)無法離開 python。

4、系統(tǒng)運維工程項目,自動化運維的標(biāo)配就是 python+Django/flask。

5、金融理財分析,量化交易,金融分析。

6、大數(shù)據(jù)分析。

關(guān)于“Ubuntu 上安裝和使用 Python3.6 的方法是什么”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對“Ubuntu 上安裝和使用 Python3.6 的方法是什么”知識都有一定的了解,大家如果還想學(xué)習(xí)更多知識,歡迎關(guān)注丸趣 TV 行業(yè)資訊頻道。

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-07-13發(fā)表,共計3019字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 湘乡市| 翼城县| 潍坊市| 齐齐哈尔市| 湘潭市| 黔西县| 乌鲁木齐市| 博客| 鸡东县| 余干县| 望江县| 肇庆市| 项城市| 克什克腾旗| 新绛县| 伊川县| 含山县| 托克逊县| 延寿县| 通州区| 兴化市| 资阳市| 潼关县| 柏乡县| 霍林郭勒市| 沙坪坝区| 略阳县| 夹江县| 海伦市| 和静县| 井陉县| 庄浪县| 凯里市| 大悟县| 宜章县| 类乌齐县| 张家口市| 龙南县| 尼勒克县| 故城县| 连州市|