Basic Flask Issue w/ Importing
Question: I'm following a Flask tutorial and am getting an import error. I have a file
called `run.py` which contains:

    
    
    from app import app
    app.run(debug = True)
    

When I run `./run.py`, I get:

    
    
    Traceback (most recent call last):
      File "./run.py", line 2, in <module>
        from app import app
      File "/Users/myName/Desktop/SquashScraper/app/__init__.py", line 1, in <module>
        from flask import Flask
    ImportError: cannot import name Flask
    

This seems similar to this issue:
`http://stackoverflow.com/questions/26960235/python3-cannot-import-name-flask`

So I attempted the checked solution by running:

    
    
    virtualenv -p /usr/bin/python3 my_py3_env
    

Unfortunately, I get:

    
    
    The executable /usr/bin/python3 (from --python=/usr/bin/python3) does not exist
    

Any ideas what may be happening here?

Thanks for the help, bclayman


Answer: If you want your virtual environment to be Python 3 but don't know the
installation directory, use `which python3`. Use that directory in your
`virtualenv -p [directory] my_py3_env` command to set up the Python 3 virtual
environment.

I sounds like your pip is installing to your Python 2.X directory. If you're
okay with that, you'll need to run the app either with `python2 run.py`,
`python2.X run.py` where `x` is your installed version, or change the symlink
of `python` in `/usr/bin/python` to your installation of Python 2.

[This](http://stackoverflow.com/questions/2812520/pip-dealing-with-multiple-
python-versions) question has some more information.

Regardless of the version of Python that you wish to use, you will need to
install Flask to _that_ version of Python. See
[this](http://stackoverflow.com/questions/10919569/how-to-pip-install-to-
specific-version-of-python) question for that.

