osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Modules


Hmm, let's try a little interactive session, shall we? Did
your error message look something like this?

    >>> import spam

    Traceback (most recent call last):
      File "<pyshell#0>", line 1, in <module>
        import spam
    ImportError: No module named spam

    >>> import eggs

    Traceback (most recent call last):
      File "<pyshell#1>", line 1, in <module>
        import eggs
    ImportError: No module named eggs

    >>> from green.eggs import ham

    Traceback (most recent call last):
      File "<pyshell#2>", line 1, in <module>
        from green.eggs import ham
    ImportError: No module named green.eggs

Hmm. It seems that python cannot find a module, then there
is no way to import it. What to do? Ah ha! We check the
search path!

    >>> import sys
    >>> sys.path
    [...List of directories...]

Q: Are your modules inside any of the listed directories?