Forums

[Flask-App] ModuleNotFoundError: No module named 'X'. A few modules cannot be found only..

Hello,

I have been trying to figure out this problem for a day and cannot find any solutions on the forums. I have created my flask app locally and then uploaded it manually on Pythonanywhere. The problem is that only a specific modules CANNOT be found/used/imported and others CAN. It's quite frustrating that I can't figure this out and I'm sure there is a simple fix to this. The list of all my packages/modules are shown below:

List of modules/packages

Please keep in mind that my flask web app launches correctly! It's just that the few web app features that rely on these modules DO not work due to the modules not being imported properly. pymongo, flask_mail, flask_pymongo, flask_reCaptcha, and flask_mongoengine CANNOT be found as shown below.

Virtualenv module flask_mongoengine not found

This shows flask_mail installed properly. flask_mail not found

And so on..... with flask_pymongo and flask_reCaptcha... same console error message..

I believe I have setup the virtualenv properly in the "Web" section in Pythonanywhere with the desired python version (3.7) as shown below.

Virtualenv setup

The WGSI file is setup properly as shown below. Please note that I originally had the default "sys.path.append(path)" but recently changed it to "sys.path.insert(0, path)" from https://help.pythonanywhere.com/pages/Flask/

sys.path print

Both did not fix my problem and both print(sys.path) directory have the same output.

Here I checked if the modules are found and installed within the activated virtualenv and they all seem to be there.

module locations

We've been discussing this on this other forum thread too, so I'll continue answering there.