TypeError: an integer is required (got type str)
Question: I am new to Python and Flask. I am working my way throught this tutorials:
<http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-iii-web-
forms> Right now i am getting an error for which i can't find a fix for. I
have reinstalled Python 3.4.3 and reinstalled the virtual environment, I have
copyed the code directly from the tutorial to make sure i did not make a
mistake while typing, still nothing works.

**init**.py

    
    
    from flask import Flask
    
    app = Flask(__name__)
    app.config.from_object('config')
    
    from app import views
    

views.py

    
    
    from flask import render_template, flash, redirect
    from app import app
    from .forms import LoginForm
    
    @app.route('/')
    @app.route('/index')
    def index():
        user = {'nickname': 'Miguel'}
        posts = [
            {
                'author': {'nickname': 'John'},
                'body': 'Beautiful day in Portland!'
            },
            {
                'author': {'nickname': 'Susan'},
                'body': 'The Avengers movie was so cool!'
            }
        ]
        return render_template("index.html",
                               title='Home',
                               user=user,
                               posts=posts)
    
    @app.route('/login', methods=['GET', 'POST'])
    def login():
        form = LoginForm()
        return render_template('login.html',
                               title='Sign In',
                               form=form)
    

forms.py

    
    
    from flask.ext.wtf import Form
    from wtforms import StringField, BooleanField
    from wtforms.validators import DataRequired
    
    class LoginForm(Form):
        openid = StringField('openid', validators=[DataRequired()])
        remember_me = BooleanField('remember_me', default=False)
    

run.py

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

The error:

    
    
    (flask) G:\microblog>python run.py
    Traceback (most recent call last):
      File "run.py", line 1, in <module>
        from app import app
      File "G:\microblog\app\__init__.py", line 6, in <module>
        from app import views
      File "G:\microblog\app\views.py", line 3, in <module>
        from .forms import LoginForm
      File "G:\microblog\app\forms.py", line 1, in <module>
        from flask.ext.wtf import Form
      File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
      File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
      File "G:\microblog\flask\lib\site-packages\flask\exthook.py", line 62, in load_module
        __import__(realname)
      File "G:\microblog\flask\lib\site-packages\flask_wtf\__init__.py", line 15, in <module>
        from .form import Form
      File "G:\microblog\flask\lib\site-packages\flask_wtf\form.py", line 15, in <module>
        from .i18n import translations
      File "G:\microblog\flask\lib\site-packages\flask_wtf\i18n.py", line 12, in <module>
        from flask_babel import get_locale
      File "G:\microblog\flask\lib\site-packages\flask_babel\__init__.py", line 21, in <module>
        from babel import dates, numbers, support, Locale
      File "G:\microblog\flask\lib\site-packages\babel\dates.py", line 28, in <module>
        from babel.util import UTC, LOCALTZ
      File "G:\microblog\flask\lib\site-packages\babel\util.py", line 278, in <module>
        from babel import localtime
      File "G:\microblog\flask\lib\site-packages\babel\localtime\__init__.py", line 21, in <module>
        from babel.localtime._win32 import _get_localzone
      File "G:\microblog\flask\lib\site-packages\babel\localtime\_win32.py", line 18, in <module>
        tz_names = get_global('windows_zone_mapping')
      File "G:\microblog\flask\lib\site-packages\babel\core.py", line 58, in get_global
        _global_data = pickle.load(fileobj)
    TypeError: an integer is required (got type str)
    

I am frustrated that i can't continue the tutorial, so any help is welcome.


Answer: The old version of babel doesn't work with 3.4. Install this update instead:

pip3.4.exe install git+<https://github.com/mitsuhiko/babel.git@2.0>

It works with Python3.4 so you no longer need to downgrade your Python.

