Finding modules in subdirectories of sys.path

Norm Wood norm at wombat.atmos.colostate.edu
Wed Aug 22 21:27:44 EDT 2001


Maan,

Thanks - after trying a few more things along the lines of your
suggestion, I think I see how it works.

If sys.path is '/home/me/lib/python2.0', then "import Physics"
doesn't work, but "import Scientific.Physics" does.

If sys.path is '/home/me/lib/python2.0/Scientific', then
"import Physics" works.

Regards,
Norm

Maan M. Hamze <mmhamze at pleiades.net> wrote:
> Norm
> I have not used these packages and I do not know how they install.  But from
> my experience in Windows - if you install packages, you should be able to
> use modules by importing packages.  so if you have these directories in
> sys.path, did you try:
> import Physics
> for example and see what happens?  Provided you have __init__.py in that
> subdirectory it should find it.  Then you can use modules from this package.
> Maan
> 
> "Norm Wood" <norm at wombat.atmos.colostate.edu> wrote in message
> news:3b841921 at news.ColoState.EDU...
>> Hi,
>>
>> I've installed the NumPy extensions and Scientific Python package into
>> subdirectories of my home directory:
>>
>> /home/me/lib/python2.0/Numeric
>> /home/me/lib/python2.0/Scientific
>>
>>
>> The Scientific directory contains a number of subdirectories (Physics,
>> Statistics, etc.).  It appears that, in order to import modules from
>> these subdirectories, each subdirectory has to be listed explicitly
>> in sys.path.  Otherwise, I get an import error.
>>
>> Is it possible to cause python to search recursively through the
>> directories rooted at /home/me/lib/python2.0?  Or is it possible
>> to place some sort of index in /home/me/lib/python2.0 so that python
>> can locate the modules within the subdirectories without explicitly
>> listing each subdirectory in sys.path?



More information about the Python-list mailing list