1
votes

I've spend an inordinate amount of time over the last few weeks trying to get this to work. My goal is to create a simple web app using the flask framework but I keep getting errors, and hours of googling and searching stackoverflow have not helped.

I'm following a tutorial that requires me to run: $ python3 routes.py

Only for me to get the following error:

Traceback (most recent call last): File "routes.py", line 1, in from flask import Flask, render_template ImportError: No module named 'flask'

Ok so Flask is not installed? So apparently every site tells me to type $ pip install Flask

warning: no files found matching '' under directory 'tests' warning: no previously-included files matching '.pyc' found under directory 'docs' warning: no previously-included files matching '.pyo' found under directory 'docs' warning: no previously-included files matching '.pyc' found under directory 'tests' warning: no previously-included files matching '.pyo' found under directory 'tests' warning: no previously-included files matching '.pyc' found under directory 'examples'

...yada yada yada...

error: could not create '/Library/Python/2.7/site-packages/flask': Permission denied

OK great. I google that error and they tell me to type more magic incantations into the terminal. "Simply do this and it will work"... except it doesn't. Nothing works.

Is anyone willing to hold my hand through this? What should I do to get things working?


Joshua:~ Joshua$ sudo pip install flask Downloading/unpacking flask Downloading Flask-0.10.1.tar.gz (544kB): 544kB downloaded Running setup.py (path:/private/tmp/pip_build_root/flask/setup.py) egg_info for package flask

warning: no files found matching '*' under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'docs'
warning: no previously-included files matching '*.pyo' found under directory 'docs'
warning: no previously-included files matching '*.pyc' found under directory 'tests'
warning: no previously-included files matching '*.pyo' found under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'examples'
warning: no previously-included files matching '*.pyo' found under directory 'examples'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'docs/_themes/.git'

Downloading/unpacking Werkzeug>=0.7 (from flask) Downloading Werkzeug-0.9.4.tar.gz (1.1MB): 1.1MB downloaded Running setup.py (path:/private/tmp/pip_build_root/Werkzeug/setup.py) egg_info for package Werkzeug

warning: no files found matching '*' under directory 'werkzeug/debug/templates'
warning: no files found matching '*' under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'docs'
warning: no previously-included files matching '*.pyo' found under directory 'docs'
warning: no previously-included files matching '*.pyc' found under directory 'tests'
warning: no previously-included files matching '*.pyo' found under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'examples'
warning: no previously-included files matching '*.pyo' found under directory 'examples'
no previously-included directories found matching 'docs/_build'

Downloading/unpacking Jinja2>=2.4 (from flask) Downloading Jinja2-2.7.2.tar.gz (378kB): 378kB downloaded Running setup.py (path:/private/tmp/pip_build_root/Jinja2/setup.py) egg_info for package Jinja2

warning: no files found matching '*' under directory 'custom_fixers'
warning: no previously-included files matching '*' found under directory 'docs/_build'
warning: no previously-included files matching '*.pyc' found under directory 'jinja2'
warning: no previously-included files matching '*.pyc' found under directory 'docs'
warning: no previously-included files matching '*.pyo' found under directory 'jinja2'
warning: no previously-included files matching '*.pyo' found under directory 'docs'

Downloading/unpacking itsdangerous>=0.21 (from flask) Downloading itsdangerous-0.24.tar.gz (46kB): 46kB downloaded Running setup.py (path:/private/tmp/pip_build_root/itsdangerous/setup.py) egg_info for package itsdangerous

warning: no previously-included files matching '*' found under directory 'docs/_build'

Downloading/unpacking markupsafe (from Jinja2>=2.4->flask) Downloading MarkupSafe-0.19.tar.gz Running setup.py (path:/private/tmp/pip_build_root/markupsafe/setup.py) egg_info for package markupsafe

Installing collected packages: flask, Werkzeug, Jinja2, itsdangerous, markupsafe Running setup.py install for flask

warning: no files found matching '*' under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'docs'
warning: no previously-included files matching '*.pyo' found under directory 'docs'
warning: no previously-included files matching '*.pyc' found under directory 'tests'
warning: no previously-included files matching '*.pyo' found under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'examples'
warning: no previously-included files matching '*.pyo' found under directory 'examples'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'docs/_themes/.git'

Running setup.py install for Werkzeug

warning: no files found matching '*' under directory 'werkzeug/debug/templates'
warning: no files found matching '*' under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'docs'
warning: no previously-included files matching '*.pyo' found under directory 'docs'
warning: no previously-included files matching '*.pyc' found under directory 'tests'
warning: no previously-included files matching '*.pyo' found under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'examples'
warning: no previously-included files matching '*.pyo' found under directory 'examples'
no previously-included directories found matching 'docs/_build'

Running setup.py install for Jinja2

warning: no files found matching '*' under directory 'custom_fixers'
warning: no previously-included files matching '*' found under directory 'docs/_build'
warning: no previously-included files matching '*.pyc' found under directory 'jinja2'
warning: no previously-included files matching '*.pyc' found under directory 'docs'
warning: no previously-included files matching '*.pyo' found under directory 'jinja2'
warning: no previously-included files matching '*.pyo' found under directory 'docs'

Running setup.py install for itsdangerous

warning: no previously-included files matching '*' found under directory 'docs/_build'

Running setup.py install for markupsafe

building 'markupsafe._speedups' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c markupsafe/_speedups.c -o build/temp.macosx-10.9-intel-2.7/markupsafe/_speedups.o
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
==========================================================================
WARNING: The C extension could not be compiled, speedups are not enabled.
Failure information, if any, is above.
Retrying the build without the C extension now.


==========================================================================
WARNING: The C extension could not be compiled, speedups are not enabled.
Plain-Python installation succeeded.
==========================================================================

Successfully installed flask Werkzeug Jinja2 itsdangerous markupsafe Cleaning up...

2
1. to install flask on the system level you need sudo, hence: sudo pip install flask (are you using windows?) 2. I'd strongly recommend using virtualenv. 3. Other than that, please post specific errors. pypi.python.org/pypi/virtualenvOleg Belousov
1. I'm on a mac. 2. I tried to install virtualenv but it didn't work. Nothing works with python. I've tried sudo this and sudo that. I've tried changing path variables and all kinds of things that were suggested that I don't understand. Nothing works. I'm afraid maybe all my internal settings are screwed up now. Errors have been posted in OP and in another thread I created: stackoverflow.com/questions/22572194/… This is a very frustrating experience. I don't understand why they have made this so complicated to do?user3441876
sudo pip install setuptools && pip install python-dev docs.python-guide.org/en/latest/starting/install/osxOleg Belousov
Did you even read my post? You think I haven't looked at that already? I'm trying to get flask to work with python 3.user3441876

2 Answers

1
votes

OK, first thing first. Flask is not installed so we will have to install it first.

When installing stuff in UNIX (a Mac, in your case), you will need root permissions. There are many ways to run stuff as root, the easiest is

sudo YOUR COMMAND HERE

so if you want to install flask, you will run:

sudo pip install flask

then, open a python shell and import flask, it should work just fine.

 My-MacBook-Pro:~ user$ python
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import flask
>>>

By the way, Enthought Canopy is a free python environment that will take care of most of your python needs, including helping you to install packages. If this doesn't work, please let me know :)

0
votes

If you want to use python 3 you will have to install flask for python 3 - you are currently only installing it on 2.7.

Easiest way, if it is configured on your system: pip-3.0 install Flask

Replace -3.0 with the version actually installed on your system.

Alternative: python3 /usr/bin/pip install Flask (pip might be installed somewhere else?)

pip: dealing with multiple Python versions?

How to install a module use pip for specific version of?