Why doesn't import work?

Alan Franzoni alan.franzoni.blahblah at example.com.invalid
Tue Aug 5 14:09:42 CEST 2008


ssecorp was kind enough to say:

> I have in Lib/site-packages a module named pdfminer. when I do import
> pdfminer it complains:
> 
>>>> import pdfminer

If you've got a directory, that's not a module - it's a package.

In order to import a directory as a package, you must create a (possibly
empty) __init__.py file in that dir.

then you can do something like

from pdfminer import pythonfile1

or you can follow Sean's advice and export the __all__ name in order to
directly access any module you like.

-- 
Alan Franzoni <alan.franzoni.xyz at gmail.com>
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E



More information about the Python-list mailing list