view raw
Brandon Foster Brandon Foster - 8 months ago 48
Python Question

Python ImportError- what is wrong here?

I am new to programming and Python. I am following the Learn Python the Hard Way book.
As a part of exercise 25, I wrote a script:

def break_words(stuff):
"""This function will break up words for us."""
words = stuff.split(' ')
return words

def sort_words(words):
"""Sorts the words."""
return sorted(words)

def print_first_word(words):
"""Prints the first words after popping it off."""
word = words.pop(0)
print word

def print_last_word(words):
"""Prints the last word after popping it off."""
word = words.pop(-1)
print word

def sort_sentence(sentence):
"""Takes in a full sentence and returns the sorted words."""
words = break_words(sentence)
return sort_words(words)

def print_first_and_last(sentence):
"""Prints the first and last words of the sentence."""
words = break_words(sentence)

I saved this from gedit as

under the path


I am running 64-bit Windows 7.

When I go to import ex25 from python.exe
I get:

> Traceback (most recent call last):
> File "(stdin)", line 1, in `<module>`
> ImportError: No module named ex25

Under Computer\Properties\Advanced\Environment Variables I added the System Variable:



That didn't help.
What am I doing wrong?


C:\Users\Brandon\Experiment\Python_ex is not on your system path, thus python is not aware where your ex25 module can be found

import sys