admin 管理员组文章数量: 1086019
When I attempt to deploy a Flask app on a shared hosting site, using cPanel, the deployment fails with this message: "ModuleNotFoundError: No module named 'imp'."
As other posts have indicated, the imp
module has been removed from Python and a different module, importlib
, should be used instead. However, the file named passenger_wsgi.py
is generated automatically any edited version will always be overwritten. It is this file that needs to use the imp
module.
How can I deploy my Flask app on shared hosting, using cPanel to set up the app?
.
When I attempt to deploy a Flask app on a shared hosting site, using cPanel, the deployment fails with this message: "ModuleNotFoundError: No module named 'imp'."
As other posts have indicated, the imp
module has been removed from Python and a different module, importlib
, should be used instead. However, the file named passenger_wsgi.py
is generated automatically any edited version will always be overwritten. It is this file that needs to use the imp
module.
How can I deploy my Flask app on shared hosting, using cPanel to set up the app?
.
Share Improve this question asked Mar 28 at 17:17 macloomacloo 6371 gold badge9 silver badges19 bronze badges1 Answer
Reset to default 0If you attempt to deploy a Flask app on a shared hosting site, using cPanel, the deployment is likely to fail with this message: "ModuleNotFoundError: No module named 'imp'." As other posts have indicated, the `imp` module has been removed from Python and a different module, `importlib`, should be used instead.
The problem comes from the cPanel deployment: a file named `passenger_wsgi.py` is generated automatically. If you stop and restart the app, this file is rewritten, and thus you cannot edit the file yourself; the edited version will always be overwritten. It is this file that needs to use the `imp` module, and as far as I could learn, cannot be replaced or modified for a cPanel deployment of any Python app.
The solution is to roll back the Python version to 3.11.11 (or earlier). The `imp` module still exists in those versions, and so `passenger_wsgi.py` will run without error, and your app will run too — so long as it can run under Python 3.11.11.
.
本文标签: Python Flask WSGI failure with deprecated imp moduleStack Overflow
版权声明:本文标题:Python Flask WSGI failure with deprecated imp module - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744022752a2520096.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论