Problems installing flask_cors module

Hi all,
Im wanting to start the course but can’t get the app to run at all. I’ve set up a virtual environment, installed the requirements and then altered the .ini file. I’m using VSCode so the modules get checked when I open the scripts and they all load fine, ie not issues found and change colour to show that they are recognised. I’ve run pip3 show to check to see if flask_cors is installed and it is. I’ve tried uninstalling it, globally installing it as well as installing it in the venv. But every time I get an error from saying that the module cant be found. So again I check that it’s installed etc etc.
In googling this, every answer just says the obvious - “you haven’t installed it”. So I try uninstalling it, installing again, checking it’s in the venv and boom, same problem.
Has anyone got any answer for this other than “use: pip3 install flask-cors” etc etc
Thanks, I’m going totally mad after hours of not fixing this.

I’ve shared a screenshot showing the venv lib, the code from the file that wont work, as well as the terminal showing both ‘pip3 show flask-cors’ and 'python

Anyone have any ideas at all about how to solve this?

Hey @Justin_Coleman,

Welcome to the MongoDB Community Forums! :leaves:

From the screenshot you attached, one thing that I’m confused about is why you are using pip3 instead of just pip if the virtual environment has been activated. Most probably, packages have been installed for one version of python and you are running the app using another. After you activate the virtual environment, can you try the following command to confirm the virtual environment python version:

python --version

If it is indeed 3.9(please note that the course has been tested with python 3.8 and that’s the recommended version), please use the following command and see if it resolves the issue:

pip install flask-cors

Alternatively, you can also try python3 instead of python since all your packages have been installed for python3.

Let us know if this resolves your issue or not. Please feel free to reach out for anything else as well.


1 Like

Hi Satyam
Thanks for the reply, it’s helped me to solve the problem.
The steps I took were:
1 - re-downloaded the materials
2 - created a virtual env and specified python3.8
3 - activated the virtualenv
4 - installed the requirements using pip not pip3
5 - cffi wouldn’t install
6 - removed cffi version number from requirements.txt and saved it
7 - installed the requirements using pip and this time it worked
8 - updated the dotini file
9 - I then tried using python but it wouldn’t work.
10 - Tried your suggestion of python3 and it does work

I’ll attach a screenshot showing the set up when trying python, in case anyone else is struggling with the same thing.
Thanks for your help. I’m very much still learning and hadn’t thought about pip vs pip3

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.