日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

BUG之路2--ubuntu安装uwsgi测试报错:failed to open python file test.py

發布時間:2023/12/20 python 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 BUG之路2--ubuntu安装uwsgi测试报错:failed to open python file test.py 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

心路歷程

毫無疑問,又是能讓我跳樓的BUG,但是結果都一樣,很小的細節,卡我兩天時間。

BUG過程:

在ubuntu上部署django項目時,需要安裝uwsgi服務器。根據教程安裝完之后,然后會有一個小測試,就是寫一個test.py文件運行一下看uwsgi是否安裝成功。具體的test.py文件我就不貼了,網上一堆。
然后重要的是在運行命令:uwsgi –http :8001 –wsgi-file test.py時,報錯了。詳細錯誤信息如下:

dh@ubuntu:~$ uwsgi –http :8001 –wsgi-file test.py
Starting uWSGI 2.0.17 (64bit) on [Mon Jun 11 12:37:29 2018]
compiled with version: 7.3.0 on 07 June 2018 06:45:48
os: Linux-4.15.0-22-generic #24-Ubuntu SMP Wed May 16 12:15:17 UTC 2018
nodename: ubuntu
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /home/dh
detected binary path: /home/dh/.local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
WARNING: you are running uWSGI without its master process manager
your processes number limit is 15072
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with –thunder-lock)
uWSGI http bound on :8001 fd 4
spawned uWSGI http 1 (pid: 18207)
uwsgi socket 0 bound to TCP address 127.0.0.1:36073 (port auto-assigned) fd 3
Python version: 3.6.5 (default, Apr 1 2018, 05:46:30) [GCC 7.3.0]
Python threads support is disabled. You can enable it with –enable-threads
Python main interpreter initialized at 0x55e5bf3e29c0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72904 bytes (71 KB) for 1 cores
Operational MODE: single process
failed to open python file test.py
unable to load app 0 (mountpoint=”) (callable not found or import error)
no app loaded. going in full dynamic mode
uWSGI is running in multiple interpreter mode
spawned uWSGI worker 1 (and the only) (pid: 18206, cores: 1)

報錯的就是最后那三句:

failed to open python file test.py
unable to load app 0 (mountpoint=”) (callable not found or import error)
no app loaded. going in full dynamic mode

報錯原因:找不到test.py文件

解決方法:

在根據教程安裝uwsgi時,我的理解是,安裝完 ,直接在django項目里寫一個test.py文件,再用命令運行就可以。
實際的步驟是:安裝完uwsgi后,在任何位置都可以寫這個test.py文件,然后打開終端運行命令時的位置必須和這個test.py文件位置相同,例如:test.py文件的路徑是/home/etc/test.py,那你終端的位置也應該是/home/etc/test.py,就不會報這個錯了。

最后再列一下安裝uwsgi的正確步驟:

1.sudo apt-get install libpcre3 libpcre3-dev ,第一步必須先安裝這個庫文件,不然不報錯:no internal routing support, rebuild with pcre support

2.sudo pip3 install uwsgi ,這里和上一篇注意的BUG一樣,如果你是python3,就一定要用pip3安裝

3.任何位置寫一個test.py,內容如下
def application(env, start_response):
   start_response(‘200 OK‘, [(‘Content-Type‘,‘text/html‘)])
   return [b”Hello World”]

4.然后啟動終端,和之前說的一樣,終端的位置要和test的文件位置相同,運行命令:uwsgi –http :8001 –wsgi-file test.py

5.瀏覽器里輸入:127.0.0.1:8001就可以看到輸出效果:Hello World

OK了

總結

以上是生活随笔為你收集整理的BUG之路2--ubuntu安装uwsgi测试报错:failed to open python file test.py的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。