flask使用中遇到的問題與解決方案


1、運行flask報錯

ModuleNotFoundError: No module named 'flask._compat'

問題解析:該問題一般是flask版本太高,高版本好像沒有了'flask._compat'所以報錯。降低flask版本即可解決

pip uninstall flask
pip install flask==1.1.4

2、報錯

tzlocal.utils.ZoneInfoNotFoundError: 'Multiple conflicting time zone configurations 
found:\n/etc/timezone: Asia/Shanghai\n/etc/localtime is a symlink to: PRC\nFix the configuration, 
or set the time zone in a TZ environment variable.\n'

問題解析:該問題是因為時區導致的問題。一個是timezone一個是localtime

vim /etc/timezone #查看設置的是否是Asia/Shanghai
rm -f /etc/localtime
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

3、使用zipfile壓縮文件報錯
給壓縮包起名時,文件名內一定不能有/,有斜杠找不到路徑(害苦了我了)
4、啟動項目失敗
報錯地址已經在使用OSError: [Errno 98] Address already in use
問題解析:一半是上次關閉flask項目表面關上了,但是后台還在運行

#解決方法
netstat -tunlp
#找到被占用的地址的pid
kill -9 pid(占用地址的pid)

5、flask項目運行后,chrome一直下載緩存中的文件
在下載獲取到response對象后,增加headers 設置 cache-controll = “no-store“


免責聲明!

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



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