初次使用uwsgi:no python application found, check your startup logs for errors


按照文檔,首先寫一個test.py的文件,進行測試是否安裝成功

1 def application(env, start_response):
2     start_response('200 OK', [('Content-Type','text/html')])
3     return ["Hello World"]

 

結果剛開始既不顯示內容,也不現實錯誤

仔細查看運行回顯:出現了一段 沒有使用 pcre,於是重新安裝 uwsgi

首先執行

sudo pip uninstall uwsgi

出現了 沒有目錄權限的提示

執行, sudo chown -R $(whoami) /***/http

然后重新執行, sudo pip uninstall uwsgi

卸載完成

重新安裝,這次沒有采用pip install uwsgi

而是,直接在https://pypi.python.org/pypi/uWSGI/ 進行下載tar包

執行

tar -xvf uwsgi-2.0.15.tar.gz

cd uwsgi-2.0.15

make

重新執行,結果一直顯示 no python application found, check your startup logs for errors

查看手冊,發現python3,需要使用下面的代碼

1 def application(env, start_response):
2     start_response('200 OK', [('Content-Type','text/html')])
3     return [b"Hello World"]

可是仍舊不行

重新查看手冊,發現,需要在命令行添加參數 --plugin python

執行下面命令行: 

uwsgi --plugin python --http :8001 --wsgi-file test.py

重新訪問 localhost:8001

就可以看到 成功的顯示了 'Hello world'

 

PS:附件為uwsgi的手冊

https://media.readthedocs.org/pdf/uwsgi-docs-additions/latest/uwsgi-docs-additions.pdf

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM