0

I'm trying to deploy a small test app to a server, but even though Flask is installed on the server, I'm still getting a "no module named flask" error every time I try to run the app on the server.

This is the error message I get, and the server telling me that Flask is already installed This is the error message I get, and the server telling me that Flask is already installed.

I have looked at some of the other solutions on this site, but I have to admit I am a complete noob and can't even understand what some of those solutions mean. There are some mentions of the path files being wrong, but I'm not sure what that means or how to fix it on the server. Can anyone explain what might have gone wrong and how to fix it?

J.J. Hakala
  • 6,136
  • 6
  • 27
  • 61
AnnieH
  • 35
  • 8
  • How do you start your server? Why don't you use a virtualenv (I know it doesn't answer directly the question, but that could be a beginning)? – Léopold Houdin Sep 17 '18 at 11:10
  • I'm using Apache2 and WSGI to deploy the app, if that's what you're asking. I'm not sure how to add a virtualenv to an already existing project, but at this point I'm ready to try anything. Do you have any good tutorials on how to do that? – AnnieH Sep 17 '18 at 11:13
  • Do you have any other versions of python installed? – Ninad Gaikwad Sep 17 '18 at 11:16
  • not as far as I know. `python -V` only shows 2.7.15rc1 – AnnieH Sep 17 '18 at 11:17
  • Please see this https://stackoverflow.com/questions/24661649/error-installing-flask-python – Mohammad Zain Abbas Sep 17 '18 at 11:27
  • python -v will only show you the python executable that is in your path. It's possible that you are either using a virtual environment without flask installed or you are using an IDE like pycharm which allows you to use different python versions for different projects. – Ninad Gaikwad Sep 17 '18 at 11:30
  • @NinadGaikwad, I used PyCharm for developing the app, but without creating a venv. I'm trying to deploy the app in a server that does not have PyCharm, however. – AnnieH Sep 17 '18 at 11:38
  • Is that error showing on your deployment server then? Or is it on your local machine? – Ninad Gaikwad Sep 17 '18 at 11:41
  • Yes, sorry, the error is on the deployment server. The flask app runs well on my local machine. – AnnieH Sep 17 '18 at 11:48
  • @MohammadZainAbbas, so if I understand that link correctly, I should create a venv for my project... and then just by copying the venv files into my deployment server it will run correctly, or do I have to configure something else? – AnnieH Sep 17 '18 at 11:49
  • @AnnieH Yeah, it should work. Try creating virtual env and then installing all the required dependencies/modules. :) – Mohammad Zain Abbas Sep 17 '18 at 14:00
  • @MohammadZainAbbas it didn't work... or am I doing it wrong? I initialized a virtualenvironment on my flask app, activated it and installed flask, but when I uploaded the code to my server it is giving me the exact same error. – AnnieH Sep 17 '18 at 14:42

1 Answers1

0

Try

help('modules')

in Python shell, this will list all the available modules as explained here (follow the steps mentioned in that post's answer)

If it still doesn't resolve your issue, then try uninstalling and reinstalling flask module.

If it still doesn't work, you can try this instead (or the answers listed below that post.)

Let me know if that works or not.

Mohammad Zain Abbas
  • 728
  • 1
  • 11
  • 24
  • Thanks, I'm still not sure what the problem was but uninstalling everything and then using venv to reinstall flask seemed to do the trick. Thank you very much. – AnnieH Sep 18 '18 at 12:46