Ubuntu18.04系统如何安装cherrypy

[复制链接] |主动推送
查看209 | 回复0 | 2024-9-12 00:46:23 | 显示全部楼层 |阅读模式
cherryPy是一个基于Python的面向对象的HTTP框架。那么在ubuntu18.04中如何安装cherrypy呢?本文给出详细说明。
1.首先确认安装了python3
000311gqlqmhoqn7ga3lim.jpg
说明:一般linux系统默认都有安装python环境,包括python2和python3,在命令行中python默认指的是python2。python2已经接近淘汰,但由于linux系统环境中还有大量基于python2的软件,因此在linux系统中还保留着python2。目前推荐使用python3。
2.更新软件列表
sudo apt-get update
000312vkp7k7she7p5p28l.jpg

3.安装python3-pip
sudo apt install python3-pip
000312ui0nnmnnc7llml75.jpg

4.安装requests库
sudo pip3 install cherrypy
000312k26ni9i5bzm3n76q.jpg

5.编写测试程序
vi hello.py
写入测试程序
import cherrypy
class HelloWorld:
@cherrypy.expose
def hello(self):
return ‘hello’
cherrypy.quickstart(HelloWorld())
6.运行
python3 hello.py

000312ldrdiggjopjfe0pg.jpg
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则