• Register
0 votes

Need help avoiding such an error, I have installed Flask using pip

pip install Flask

I needed to import Flask for a simple project but getting the following error while running my project

Traceback (most recent call last):
File "blogpost.py", line 17, in
ImportError: cannot import name 'Flask'

can anyone know why this happens and how to resolve?

10 7 2
6,060 points

Please log in or register to answer this question.

1 Answer

–1 vote

This is a handy error most people face while starts developing in python environment. Make sure you try several ways before smiling-

If you are using python3 (people started to forget about python2 already) try-

pip3 install Flask

You can also specify the version of Flask by

pip3 install Flask==0.13.2

→ Another reason could be the python file name which doesn’t mean to be ‘flask’ anyway which matches flask library file name. If that is the case-

*** Renaming the ‘flask.py’ to ‘somethingelse.py’ may help.  

11 6 4
34,950 points

Related questions

1 vote
1 answer 189 views
Problem: I am working on a django project. But when I try to make migration to the projects using the command: python manage.py makemigrations & python manage.py migrate But this does not work and an error message appears: The above exception was the direct cause of ... def __str__(self): """Return string representation of user""" return self.email Whats is the problem that is causing the error?
asked Apr 29, 2020 samhaz 5k points
0 votes
1 answer 295 views
when I am running this code i get an import errror import numpy as np import os import six.moves.urllib as urllib import sys import tarfile import tensorflow as tf import zipfile from collections import defaultdict from io import StringIO from matplotlib import ... recent call last): File "test.py", line 31, in from utils import label_map_util ImportError: cannot import name 'label_map_util'
asked Oct 25, 2020 psandprop 2.4k points
0 votes
1 answer 14 views
12 I have two files. The first one has the connection and the getting of data. I import mysql.connector. This file is called tasksSql.py def get_users(): import mysql.connector con = mysql.connector.connect(user='****', password='*****', host='', ... , this isn't working! When I import the file, it gives me the error: ImportError: No module named mysql.connector What am I doing wrong?
asked Oct 24, 2020 psandprop 2.4k points
1 vote
1 answer 100 views
Problem: I tried to install tkinter in my system and tried to run the following code: import tkinter as tk q = tk.Tk() q.title('Total Members') button = tk.Button(q, text='Welcome Members', width=25, command=q.destroy) button.pack() q. ... _tkinter.TclError: no display name and no $DISPLAY environment variable ImportError: No module named '_tkinter How can I solve this error? Thanks in advance.
asked May 4, 2020 samhaz 5k points
0 votes
1 answer 8 views
Problem: __future__ import print_function ; to bring the print function from Python 3 into Python 2.6+. __future__ statements need to be near the top of the file because they change fundamental things about the language, and so the compiler needs to know about them from the beginning
asked Jan 11 Mashhoodch 9.3k points
0 votes
3 answers 20 views
When trying to print out with a separator and end but it is still giving a syntax error on python 2.7. Here is the code: from __future__ import print_function import sys, os, time for x in range(0,10): print x, sep=' ', end='' time.sleep(1) And here is the error: $ python2 xy.py File "xy.py", line 5 print x, sep=' ', end='' ^ SyntaxError: invalid syntax $
asked Oct 24, 2020 psandprop 2.4k points
0 votes
1 answer 5 views
Problem : importerror: cannot import name '_validate_lengths'
asked 4 days ago Shovo210 2.9k points
0 votes
1 answer 10 views
Problem: from pip import main importerror: cannot import name 'main'
asked Feb 17 charles mathews 3.8k points
0 votes
1 answer 30 views
Problem: I am having an error of ImportError while trying to import _weakref. The error message looks like this: ImportError: cannot import name _remove_dead_weakref I understand something sneaky happened there in my codes but couldn’t identify the point of error. ... ;ll have a feasible solution from this forum. I am looking forward to reading your solutions. Thanks for your concern.
asked Jun 21, 2020 adamSw 11.3k points