0

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?

.

asked Mar 28, 2025 at 17:17

1 Answer 1

0

If 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.

.

answered Mar 28, 2025 at 17:17
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.