Ubuntu18.04体系如何安装cherrypy
资讯
2025-03-02 16:23
151
Ubuntu18.04系统化如何安装cherrypy
cherryPy是一个基于Python的面向对象的HTTP框架体系。那么在ubuntu18.04中如何安装cherrypy呢?本文给出详尽说明。
1.首先确认安装了python3
说明:一般linux系统化默认都有安装python环境,包括python2和python3,在命令行中python默认指的是python2。python2已经接近淘汰,但由于linux系统化环境中还有大量基于python2的运用软件,因此在linux系统化中还保留着python2。目前推荐使用python3。
2.提升运用软件列表
sudo apt-get update
3.安装python3-pip
sudo apt install python3-pip
4.安装requests库
sudo pip3 install cherrypy
5.编写验证软件
vi hello.py
写入验证软件
import cherrypy
class HelloWorld:
@cherrypy.expose
def hello(self):
return ‘hello’
cherrypy.quickstart(HelloWorld())
6.运行
python3 hello.py