I need some help with flask

I keep getting this error whenever I try to run my REPL, This worked yesterday but doesnt work today.
ImportError: cannot import name 'Flask' from 'flask' (unknown location)

I have tried uninstalling and reinstalling flask, but I get this error when I try using pip.
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/home/runner/NexusFlow/venv/lib/python3.10/site-packages/Flask-2.2.3.dist-info/METADATA'

Here is all of the imports where I get the error.

from flask import Flask, jsonify, make_response, request, redirect, render_template, url_for
import sys
from json import loads
from werkzeug.security import generate_password_hash, check_password_hash
from flask_sqlalchemy import SQLAlchemy
from functools import wraps
import uuid
from flaskext.markdown import Markdown
from sqlalchemy.inspection import inspect
import jwt
from datetime import datetime, timedelta

EDIT:
the solution was to delete and recreate the virtual envronment

Flask is currently installed using poetry, not pip. You can install it with pip if you’d like but right now it’s installed with poetry.
poetry remove flask
poetry add flask

I have tried this in the REPL’s shell however I now get this error when I try and run those commands

ImportError: cannot import name 'main' from 'poetry.console' (unknown location)

That’s a weird error message. Poetry should always work as it is Replit’s built-in package manager. Try creating a blank Flask repl and copying the config file contents into this Repl.

I’m using a Github repo so I pushed to it from the original REPL and pulled it to a new REPL but I still get the error:

Traceback (most recent call last):
  File "app.py", line 1, in <module>
    from flask import Flask, jsonify, make_response, request, redirect, render_template, url_for
ImportError: cannot import name 'Flask' from 'flask' (unknown location)

You said you tried using pip to uninstall and poetry to install. Have you tried using pip to install?

I tried using pip for the new REPL but I get this error

Looking in indexes: https://package-proxy.replit.com/pypi/simple/
Requirement already satisfied: flask in ./venv/lib/python3.10/site-packages (2.2.3)
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/home/runner/nexusflow/venv/lib/python3.10/site-packages/Flask-2.2.3.dist-info/METADATA'

I am trying to delete the virtual environment from the github repository and then ill try pulling it again

The virtual environment was the issue something messed up with it, Deleting it in the github repository and recreating it seemed to work to fix my issue

Well then you can mark this topic as solved. Probably use your post as the solution as you seem to have solved it yourself.

@Minejerik please press the “mark as solution” button below your post so that people will recognize that no more help is needed and the topic will auto-close.

2 Likes

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