Showing posts with label flask. Show all posts
Showing posts with label flask. Show all posts

Thursday, September 22, 2016

Flask on Windows and the case of the Pip install failing

At work I have a Mac and back home I have a Linux (Fedora) and Windows 10 machines. I started a Flask project on the Mac and then put it in a Github repo which I then cloned on my Windows 10 machine. And this is where I encountered the problem of pip failing to install the modules. I tried two variations to the call:
  1. > pip install -r requirements.txt
  2. > python -m pip install -r requirements.txt
This is with Python 3 and both will spit out a "Permission Denied" error relating to your appdata/Temp folder. The contents of my requirements.txt is pretty tame.

Here's a partial.

Flask==0.11.1
Flask-RESTful==0.3.5
Flask-Webpack==0.1.0
get==0.0.0
itsdangerous==0.24

It fails right on the get module. It say something like it can access the temp folder on your Windows machine which put me on a wild goose chase because the error isn't fucking related to permissions. I figured out the fix after watching the temp folder while pip attempted to install the modules.

Apparently, the Windows pip version does something really weird with the setup.py and/or egginfo where it attempts a build on a empty setup folder for the get module causing the error. The fix is to just change the version. In this case for get==0.0.0 to get==0.0.20.

The pip install command should go off with no problems now.


Monday, February 9, 2015

Stop asking me which one: Flask vs Web.py

I'm writing this entry because I've been asked the same question at events and on the internet too many times: "Which one to use, flask vs web.py?" I'm also doing this to clarify my reasons on why I like Flask better than web.py.

Disclaimer: this is more of an personal opinion rather than a more true technical comparison.

Flask and Web.py are these Python micro-architectures for building web sites and applications. Django is also a Python framework for building websites but it's whale huge so Django is out.

Age
The age of the framework matters because it helps you "find stuff" for it; find stuff, I mean like StackOverflow pages, blog entries, github projects and such. Also it makes for a good chance that someone already has solved your problem and was good enough to post it somewhere on the web.

Web.py is older and Flask is a bit more recent.

I like new.

Code-wise
Programmers and coders eventually develop a particular "taste" on how to write or organize code. This is another bias of mine because I prefer how Flask's code looks vs Web.py's.

Let's take both framework's "hello world" examples.

This is Flask's way:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()

This is Web.py's way:

import web
        
urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello:        
    def GET(self, name):
        if not name: 
            name = 'World'
        return 'Hello, ' + name + '!'

if __name__ == "__main__":
    app.run()

I like annotations better than route lists but that's just me.

Use cases
I have a pretty simple use case because I only run these things in a Google app engine instance. Both flask and web.py are supported by GAE.

Here's a flask starter for GAE and here's the web.py cook book page for GAE.

I still like Flask.

In the end
Personally, I think the question is relatively moot since both micro-frameworks do roughly the same thing. Although, web.py is older it is still actively developed and it's community is still ticking. Flask is newer but it's still a bit rough around the edges.

I'm a Flask kind of guy.