• Register
0 votes
34 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

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 112 views
112 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 samhaz 5k points
0 votes
1 answer 13 views
13 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 psandprop 2.4k points
0 votes
1 answer 22 views
22 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 adamSw 11.3k points
0 votes
1 answer 6 views
6 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 psandprop 2.4k points
1 vote
1 answer 56 views
56 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 samhaz 5k points