Ubuntu18.04系統(tǒng)如何安裝Pyramid
Pyramid 是一個小型、快速、實際的python web框架。那么在ubuntu18.04中如何安裝Pyramid呢?本文給出詳細說明。
1.首先確認安裝了python3
說明:一般linux系統(tǒng)默認都有安裝python環(huán)境,包括python2和python3,在命令行中python默認指的是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 install python3-pip
4.安裝requests庫
sudo pip3 install Pyramid
5.編寫測試程序
vi hello.py 寫入以下內(nèi)容 from wsgiref.simple_server import make_server from pyramid.config import Configurator from pyramid.response import Response def hello_world(request): return Response('hello world') if __name__ == '__main__': with Configurator() as config: config.add_route('hello','/') config.add_view(hello_world,route_name='hello') app = config.make_wsgi_app() server = make_server('0.0.0.0',6543,app) server.serve_forever()
保存退出
6.測試
python3 hello.py
在瀏覽器訪問ip:6543
版權(quán)保護: 本文「Ubuntu18.04系統(tǒng)如何安裝Pyramid」由 云主機配置專家 原創(chuàng),轉(zhuǎn)載請保留鏈接: http://www.iqcg.cn/docs/system/810.html