module name not recognized

Fredrik Lundh fredrik at pythonware.com
Sun Oct 10 09:39:15 CEST 2004


Darren Dale wrote:

>I have built two basic modules using distutils. One of them installs fine,
> but the other, I can't import modules from it. I've been pouring over the
> code and I cant find the problem.
>
> I know the file has been copied to site-packages/mypackage, but I cant do
>
> from mypackage import mymodule

really?  do you mean that you could type that into your mail program, but
not into a Python program?  that's weird... (read on)

> Could I get suggestions as to why a module would be installed but not
> registered?

if you run python with the -vv option, it tells you where it looks.

    $ python -vv
    ...
    >>> from mypackage import mymodule
    # trying mypackage.so
    # trying mypackage.py
    # trying mypackage.pyc
    ...

btw, note that if that import finds a mypackage without a mymodule,
it says

    ImportError: cannot import name mymodule

if it cannot find mypackage itself, it says

    ImportError: No module named mypackage

(this is why you should *always* include tracebacks when asking about
an error...  "can't do" or "doesn't work" or "an error" or even "an import
error" doesn't contain all the information you have, so you're forcing us to
guess.  don't do that, if you can avoid it)

</F> 






More information about the Python-list mailing list