Question

I'm an absolute beginner using IDLE (Python 2.6.4) to learn the basics. I recently found a Python program that I want to run but it throws an error although the code looks fine (i.e all modules exist):

from css.parse import parse

data = """
    em {
    padding: 2px; 
    margin: 1em;
    border-width: medium;
    border-style: dashed;
    line-height: 2.4em;
    }
    p { color: red; font-size: 12pt }
    p:first-letter { color: green; font-size: 200% }
    p:first-line { color: blue }"""

for rule in parse(data):
    print rule

for decl in parse(data)[0]:
    print decl

Error:

ImportError: No module named parse

How do I fix this? I'm using Snow Leopard.

Edit: I guess its a PATH issue, where should I place the modules, which directory?

Was it helpful?

Solution

You should have your test.py script in the same folder as the folder, not in the folder.

So it should look like this:

../
 test.py
 css/

OTHER TIPS

A generic but useful reference regarding the way Python module search path is
this brief but informative section of Python Documentation

The default paths and the environmental variables which allow configuring this important feature of the interpreter varies with different Operating Systems, so it is important to know this info for troubleshooting situations similar to that of Nimbuz.

Also the IDEs themselves can add yet another layer of configuration/indirection...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top