< 返回新闻公告列表

Ubuntu18.04系统如何安装bottle

发布时间:2023-4-6 17:12:30    来源: 纵横云

Ubuntu18.04系统如何安装bottle

bottle是一个轻巧的Python WSGI Web框架。单一文件,只依赖 Python标准库。那么在ubuntu18.04中如何安装bottle呢?本文给出详细说明。

1.首先确认安装了python3

Ubuntu18.04系统如何安装bottle-1419

说明:一般linux系统默认都有安装python环境,包括python2和python3,在命令行中python默认指的是python2。python2已经接近淘汰,但由于linux系统环境中还有大量基于python2的软件,因此在linux系统中还保留着python2。目前推荐使用python3。

2.更新软件列表

sudo apt-get update

3.安装python3-pip

sudo apt-get install python3-pip

4.安装bottle

sudo pip3 install bottle

5.创建一个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

Ubuntu18.04系统如何安装bottle-1420

7.打开浏览器输入主机ip:8000测试

安装成功

Ubuntu18.04系统如何安装bottle-1421
19906048601
19906048601 19906048601
返回顶部
返回顶部 返回顶部