Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Flask Basics Character Builder Starting the Builder

Bernardus Ivan
Bernardus Ivan
3,928 Points

what installed packages need to run this app.py if setup python local machine?

what installed packages need to run this app.py if setup python local machine? when i use pip freeze

(Flask-Basic-Finish)ivan@ivan-MS-7640:~/Flask-Basic-Finish$ pip freeze












why i am asking this :


TypeError: Expected bytes
Traceback (most recent call last)

    File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/flask/app.py", line 1836, in __call__

    return self.wsgi_app(environ, start_response)

    File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/flask/app.py", line 1820, in wsgi_app

    response = self.make_response(self.handle_exception(e))

    File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/flask/app.py", line 1403, in handle_exception

    reraise(exc_type, exc_value, tb)

    File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise

    raise value

    File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/flask/app.py", line 1817, in wsgi_app

    response = self.full_dispatch_request()

    File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/flask/app.py", line 1477, in full_dispatch_request

    rv = self.handle_user_exception(e)

    File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/flask/app.py", line 1381, in handle_user_exception

    reraise(exc_type, exc_value, tb)

    File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise

    raise value

    File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/flask/app.py", line 1475, in full_dispatch_request

    rv = self.dispatch_request()

    File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/flask/app.py", line 1461, in dispatch_request

    return self.view_functions[rule.endpoint](**req.view_args)

    File "/home/treehouse/workspace/app.py", line 41, in save

    response.set_cookie('character', data)

    File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/werkzeug/wrappers.py", line 1008, in set_cookie


    File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/werkzeug/http.py", line 920, in dump_cookie

    value = to_bytes(value, charset)

    File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/werkzeug/_compat.py", line 186, in to_bytes

    raise TypeError('Expected bytes')

    TypeError: Expected bytes

The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.

To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

    dump() shows all variables in the frame
    dump(obj) dumps all that's known about the object

that the reason

Hi Bernardus Ivan, I've formatted some of the response/error code you received to make it a bit easier to read.

Unfortunately I have no idea what could be happening here.

Kenneth Love, any ideas?

1 Answer

This is an old question, but I had similar issues so I'll add this. The only thing I found that did a nice job getting flask to run local was Anaconda. It seems to have all the dependencies. In python 3.6 (which I have installed) request is no longer an import it has to be downloaded. Anaconda made it as simple as downloading it from them. Flask installed seamlessly as well. I haven't done it yet but from what I understand, Anaconda does virtual environments as well, in case you have different dependencies for different projects.