0

I am trying to run flask using python 2.7 on a Raspberry Pi3 but I cannot seem to be able to accomplish this.

Steps that were taken already:

  1. Installed flask using:

    pip install Flask

  2. After trying to import flask with:

    from flask import Flask

I got back:

ImportError: cannot import name Flask

So, I tried to install it using:

sudo apt-get install python-flask

after I have uninstalled with sudo apt autoremove python-Flask

but still, no luck as I get the same exact error when trying to import flask.

Any suggestions?

  • 2
    Did you name your file flask.py? – ben_nuttall Jan 27 at 22:07
  • I setup Flask as required without me changing any name of any file. My own file (the one I am using to import flask) has another name... – Michael Perakis Jan 28 at 14:28
  • Michael, if you want people to know you're responded, it's a good idea to use something like @ben_nuttall to let them know. Do you get the same error with python3? Try from a clean start shell interpreter instead. Also, can you give us the full error, from the line you enter 'from flask import Flask' to the end. Also what happens if you just do 'import flask'? – T. M. Jan 28 at 20:49
  • It's a common mistake to name your flle the same as what you're importing, and this is the error you get when you do that. It doesn't have to be the file you're running, it could be another file in the same location, or even a folder called flask in the same location. – ben_nuttall Jan 28 at 22:05
  • @ben_nuttall I am not having the same name. – Michael Perakis Jan 29 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.