1

i am facing this error, i also installed flask-pymongo library, but it stills showing an error, i tried many different ways, but its the same error when i am using it. is there any way to resolve it. also i am sharing my code below.

from flask import Flask

from flask_pymongo import PyMongo

from bson.json_util import dumps

from bson.objectid import ObjectId

from flask import jsonify, request

from werkzeug.security import generate_password_hash, check_password_hash

app = Flask(__name__)

app.secret_key = "secretkey"

app.config['MONGO_URI'] = "mongodb://localhost:27017/Users"

mongo = PyMongo(app)

if __name__ == "__main__":
    app.run(debug=True)
Ken Kinder
  • 12,654
  • 6
  • 50
  • 70
Saad Alam
  • 11
  • 1
  • 2
  • Hi Saad. It would probably help if you posted the traceback you're actually seeing. You mentioned the error in your title, but the full traceback in the question body would be better. Also remember to format code using Markdown. It helps everyone read it. – Ken Kinder Jan 30 '20 at 10:40
  • Are you sure you installed this lib? Maybe you are using a virtual environment and accidentally installed lib to real one or vise versa? – Charnel Jan 30 '20 at 11:11

1 Answers1

0

Make sure you have installed the package within the environment you are running.

For example if you have installed the package globally but you run this script from within a new virtual environment (venv) then it will throw an error. So from within the venv run the pip install commands and then try running this script.

Spectrum
  • 340
  • 1
  • 4
  • 18