How to install local module other than in "site-packages"?

Benjamin Kaplan benjamin.kaplan at case.edu
Sun Jan 17 21:15:50 EST 2010


On Sun, Jan 17, 2010 at 8:09 PM, Jive Dadson <notontheweb at noisp.com> wrote:
> Okay, I might go this route anyway.  It's almost working.
>
> I created a directory (folder in MS-speak) named Modules, and put its path
> in the PYTHONPATH env variable.
>
> I can now put a file foo.py into the directory Modules, and it will load
> foo.py when I say "import foo."
>
> Now I put a folder into Modules called myModule and in that I put bar.py.
>  It does not find bar.py when I say either import bar or import
> myModule.bar.  I tried the myModule.pth trick but it didn't help.  Maybe I
> did it wrong.

Just put a blank file called __init__.py inside myModule

In Python, packages have to have an __init__.py file in them, even if
it's empty. Whatever you put in __init__.py gets imported when you
"import myModule".

http://docs.python.org/tutorial/modules.html#packages

> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list