Exercise 50: Can not get onto the web

Hi , I am looking for assistance in terminal for this chapter. I am trying to access the web with this command :
$ python bin/app.py and I get this message :
" $ python bin/app.py
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can’t open file ‘bin/app.py’: [Errno 2] No such file or directory

As well, when I go to the web browser I get this error message:
"File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/web/httpserver.py”, line 281, in log
print >> outfile, utils.safestr(msg)
IOError: [Errno 32] Broken pipe
If someone could help me out I would appreciate it very much.

Helllo @rburns.

It looks like you may be in wrong folder to run ”python bin/app.py".
Where are you when you run this? For this command /path to file you need to be one folder above bin/
Does the command pwd (print working directory) works in Mac? In linux it will tell me where I am.
My “Tree” looks like this.


I think you need to put your app.py at this level. Otherwise app.py will not find the .html files that goes in templates/ .

I have to correct myself a little!
This also works (see below).
And it looks more like the project directory tree in exercise 50


First you need to be in the right directory and have the file available. You need to do this:

ls bin/
cat bin/app.py

If any one of those fails then you’re in the wrong location. Now, after that, I’m not sure what the 2nd error is since, technically, you shouldn’t be getting it at all if the first error happened. Try to get it running then see what you get next.

Hi Ulf, thank you for your help. I understand what you are saying. I believe my problem is using Linux on my Imac. I jumped into Python not knowing any other language. When I use pwd, I get a very “bare” tree.
It looks like this:
When I use pwd nothing happens.
But, when I use “ls” on gothonweb I get a list of all the relevant directories… bin, docs, gothonweb, templates, tests.
It does appear I need to learn how to set up directories in Linux, as I have the directories and files but they are not connected .
Would there be a work around for that ?
Thanks very much once again.

Hello @rburns.
Python is also my first programing language.
Just tried some bash scripts.
But I have used Linux for years.

Both Linux and Mac are like Unix.
They share a lot of commands that works in a terminal.
mkdir (to make a new directory)
cd ( to change directory)
ls ( lists all files, folder in the current folder)
pwd ( tells you in which directory you are at the moment)

the command pwd tells you are in directory: foldername0
If you need a new folder(directory) inside this folder, just write in the terminal: mkdir foldername1
Then you want to go in there to start working:
cd foldername1.

You can create an empty textfile with touch textfile.txt.
The “tree” would look like this now:


Both Linux and Mac has texteditor nano and often vim installed. vim can be very effective editor when one have learned all functions.
You can start working with the file in the same folder:
nano textfile.txt.
Or from a folder above:
nano foldername1/textfile.txt
Or from a folder above that:
nano foldername0/foldernam1/textfile.txt

I have corrected my previous answer a little bit

My solution for lexicon_test.py

def scan(s):

words = s.split()

this = []

direction = ['north', 'south', 'east', 'west']

verbs = ['go', 'kill', 'eat','smack']

stops = ['the', 'in', 'of']

nouns = ['bear', 'princess']

numbers = ['1234', '3', '91234']    

for i in words:

    if i.lower() in direction:

        this.append(('direction', i))

    elif i.lower() in verbs:

        this.append(('verb', i))

    elif i.lower() in stops:

        this.append(('stop', i))

    elif i.lower() in nouns:

        this.append(('noun', i))

    elif i.lower() in numbers:

        this.append(('number', int(i)))


        this.append(('error', i))

return this

and my test file for parser.

from nose.tools import *

from ex48 import parser

def test_verb():

word_list = [('stop','to'),('verb','run'),('direction','smack')]

result = [('verb','run'),('verb','smack')]

for i in result:    


def test_object():

word_list = [('noun','bear'),('direction','east'),('direction','north')]

result = [('noun','bear'),('direction','east'),('direction','north')]

for i in result:


def test_subject():

word_list = [('noun','bear'),('verb','run'),('verb','smack')]

result = [('noun','bear'),('noun','player'),('noun','player')]

for i in result:


def test_sentence():

word_list = [('noun','bear'),('verb','run'),('direction','east')]

obj = (parser.Parse().parse_sentence(word_list))   

A free service run by Zed A. Shaw for learncodethehardway.org.