Ubuntu18.04系統(tǒng)如何安裝bottle
Ubuntu18.04系統(tǒng)如何安裝bottle
bottle是一個輕巧的Python WSGI Web框架。單一文件,只依賴 Python標(biāo)準(zhǔn)庫。那么在ubuntu18.04中如何安裝bottle呢?本文給出詳細說明。
1.首先確認(rèn)安裝了python3
說明:一般linux系統(tǒng)默認(rèn)都有安裝python環(huán)境,包括python2和python3,在命令行中python默認(rèn)指的是python2。python2已經(jīng)接近淘汰,但由于linux系統(tǒng)環(huán)境中還有大量基于python2的軟件,因此在linux系統(tǒng)中還保留著python2。目前推薦使用python3。
2.更新軟件列表
sudo apt-get update
3.安裝python3-pip
sudo apt-get install python3-pip
4.安裝bottle
sudo pip3 install bottle
5.創(chuàng)建一個bottle程序
vi hello.py
在其中寫入
from bottle import route,run
@route('/')
def hello():
return 'hello bottle'
run(host='0.0.0.0',port=8000,debug=True)
保存退出
6.運行hello.py
python3 hello.py
7.打開瀏覽器輸入主機ip:8000測試
安裝成功