• Register
0 votes
92 views

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'
root@home:~/Projects/python/blogProject$

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 260 views
260 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 32 views
32 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='127.0.0.1', ... , 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 148 views
148 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 42 views
42 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 13k points
0 votes
3 answers 30 views
30 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
1 vote
1 answer 21 views
21 views
Problem: Why I get this message ? Import Error On Keras ‘ Can not import names ‘abs’.
asked Mar 30 PkGuy 23.5k points
1 vote
1 answer 3 views
3 views
Problem: Why I got the error : python importerror: cannot import name
asked Mar 20 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 613 views
613 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 13 views
13 views
Problem: I'm running on Python 3.6.5 (64bits) trying to run the object_detection_tutorial. I receive this message when I run the programm : ImportError: cannot import name 'label_map_util' Any idea on what I should do ? Edit : I tried to ... object_detection/protos/label_map_util_test.py python: can't open file 'object_detection/protos/label_map_util_test.py': [Errno 2] No such file or directory
asked Apr 26 Supti 13k points