<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<a class="moz-txt-link-abbreviated" href="mailto:genkuro@gmail.com">genkuro@gmail.com</a> wrote:
<blockquote
 cite="mid1176914096.493758.77120@o5g2000hsb.googlegroups.com"
 type="cite">
  <pre wrap="">I thought import used relative paths from either the python executable
or the script being executed.  I have a script pulling in code from an
arbitrary directory.  How is this happening?

It's a RHEL 4 environment by the way.  I couldn't find any relevant
environment variables.

Thanks from a newbie for any insight.

  </pre>
</blockquote>
See ....<br>
<blockquote><a class="moz-txt-link-freetext" href="http://docs.python.org/tut/node8.html#SECTION008110000000000000000">http://docs.python.org/tut/node8.html#SECTION008110000000000000000</a><br>
  <h2>6.1.1 The Module Search Path </h2>
  <p>When a module named <tt class="module">spam</tt> is imported, the
interpreter searches
for a file named <span class="file">spam.py</span> in the current
directory,
and then in the list of directories specified by
the environment variable <a class="envvar" id="l2h-19" xml:id="l2h-19">PYTHONPATH</a>.
This has the same syntax as
the shell variable <a class="envvar" id="l2h-20" xml:id="l2h-20">PATH</a>,
that is, a list of
directory names. When <a class="envvar" id="l2h-21" xml:id="l2h-21">PYTHONPATH</a>
is not set, or when the file
is not found there, the search continues in an installation-dependent
default path; on <span class="Unix">Unix</span>, this is usually <span
 class="file">.:/usr/local/lib/python</span>.
  </p>
  <p>Actually, modules are searched in the list of directories given by
the variable <code>sys.path</code> which is initialized from the
directory containing the input script (or the current directory),
  <a class="envvar" id="l2h-22" xml:id="l2h-22">PYTHONPATH</a> and the
installation-dependent default. This allows
Python programs that know what they're doing to modify or replace the
module search path. Note that because the directory containing the
script being run is on the search path, it is important that the
script not have the same name as a standard module, or Python will
attempt to load the script as a module when that module is imported.
This will generally be an error. See section <a
 href="http://docs.python.org/tut/node8.html#standardModules">6.2</a>,
``Standard Modules,'' for more information.<br>
  </p>
</blockquote>
<p>Then try<br>
</p>
<blockquote>import sys<br>
sys.path<br>
</blockquote>
<p><br>
</p>
</body>
</html>