Ubuntu18.04系统如何安装cherrypy
page-break-inside: auto; page-break-before: auto; page-break-after: auto;">cherryPy是一个基于Python的面向对象的HTTP框架。那么在ubuntu18.04中如何安装cherrypy呢?本文给出详细说明。
page-break-inside: auto; page-break-before: auto; page-break-after: auto;">1.首先确认安装了python3
page-break-inside: auto; page-break-before: auto; page-break-after: auto;">
page-break-inside: auto; page-break-before: auto; page-break-after: auto;">说明:一般linux系统默认都有安装python环境,包括python2和python3,在命令行中python默认指的是python2。python2已经接近淘汰,但由于linux系统环境中还有大量基于python2的软件,因此在linux系统中还保留着python2。目前推荐使用python3。
page-break-inside: auto; page-break-before: auto; page-break-after: auto;">2.更新软件列表
sudo apt-get update
page-break-inside: auto; page-break-before: auto; page-break-after: auto;">
page-break-inside: auto; page-break-before: auto; page-break-after: auto;">3.安装python3-pip
sudo apt install python3-pip
page-break-inside: auto; page-break-before: auto; page-break-after: auto;">
page-break-inside: auto; page-break-before: auto; page-break-after: auto;">4.安装requests库
sudo pip3 install cherrypy
page-break-inside: auto; page-break-before: auto; page-break-after: auto;">
page-break-inside: auto; orphans: 2; widows: 2; background: #ffffff; page-break-before: auto; page-break-after: auto;" align="left">5.编写测试程序
vi hello.py
写入测试程序
import cherrypy
class HelloWorld:
@cherrypy.expose
def hello(self):
return ‘hello’
cherrypy.quickstart(HelloWorld())
page-break-inside: auto; orphans: 2; widows: 2; background: #ffffff; page-break-before: auto; page-break-after: auto;" align="left">6.运行
python3 hello.py
page-break-inside: auto; orphans: 2; widows: 2; background: #ffffff; page-break-before: auto; page-break-after: auto;" align="left">
版权保护: 本文「Ubuntu18.04系统如何安装cherrypy」由 云主机配置专家 原创,转载请保留链接: https://www.miandns.com/docs/system/828.html