(Please don't top-post replies. Instead, reply in-line with the quoted
material, removing irrelevant material. An example is this message.)

Catherine Moroney <catherine.m.moro...@jpl.nasa.gov> writes:

> I've looked at my sys.path variable and I see that it has a whole
> bunch of site-package directories, followed by the contents of my
> $PYTHONPATH variable, followed by a list of misc site-package
> variables (see below).

Can you show the full list here? What does ‘sys.path’ actually contain
when your Python interpreter is running?

> I've verified that if I manually reverse the order of sys.path I can
> then import the proper version of the module that I want.

I think the PEP 328 relative import feature is likely to be what you
want: you can specify that a specific import should search for the file
relative to the current module's file, instead of from ‘sys.path’.

As described earlier, by working through the Python tutorial
<URL:http://docs.python.org/tutorial/> you will learn about the
different styles of import statement, including relative versus absolute
<URL:http://docs.python.org/tutorial/modules.html>.

> But, I'm curious as to where the first bunch of 'site-package' entries
> come from. The
> /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg
> is not present in any of my environmental variables yet it shows up as
> one of the first entries in sys.path.

That's probably there because you have used the Setuptools system (or
something related) to install a third-party package. That is achieved by
meddling with the start-up module search path, to make the third-party
package available for import. The result is often a messy search path.

Python's system for installing third-party components is far from ideal;
it has seen a lot of improvement recently, but on the other hand is
carrying a lot of baggage from its earlier design. This is one of the
symptoms.

> Thanks for the education,

I hope that helps!

-- 
 \        “To me, boxing is like a ballet, except there's no music, no |
  `\       choreography, and the dancers hit each other.” —Jack Handey |
_o__)                                                                  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to