Python Problem

Carsten Haese carsten at uniqsys.com
Fri Sep 7 23:01:37 EDT 2007


On Fri, 2007-09-07 at 21:58 -0400, Wiseman wrote:
> Hi,
> 
> The line:
> 
> import enchant
> 
> works perfectly OK when I call a Python progrma (sp.py) from IDLE
> (WInXP). When I try to run it ftom the command line (python sp.py) the
> response is:
> 
> Traceback (most recent call last):
>    File "sp.py", line 3, in <module>
>      import enchant
> ImportError: No module named enchant

Enchant is a third-party package that must have been installed
separately. The most likely cause for the problem you're seeing is that
you have two Python versions on your computer, one with Enchant
installed, one without, and you're running the GUI of the one that does
have Enchant and the command line of the one that doesn't.

It's possible that the cause is something else, but to eliminate the
most obvious solution, run "import sys; print sys.version" in each
Python and check if they differ.

> Searching my computer (the whole of drive c:\) I could not find ANY
> file called enchant.*.

It is not necessary to have a file called enchant-dot-anything anywhere
on your disk to successfully import enchant as a module. The module
could also be built-in, stored inside a zip-file, or it could be a
package.

In enchant's case, it's a package, i.e. somewhere on your disk you'll
find a folder called "enchant" with a file "__init__.py" inside it.

To find out quickly where "enchant" is, simply issue "print enchant"
after importing enchant in IDLE. It'll tell you from where the module
was loaded.

HTH,

-- 
Carsten Haese
http://informixdb.sourceforge.net





More information about the Python-list mailing list