Python 2.1.1 ... stupid error in import.c

Tim Roberts timr at probo.com
Sun Aug 26 00:38:34 EDT 2001


Armin Steinhoff <a-steinhoff at web.de> wrote:
>
>Hi,
> to all who are porting 2.1.1 to a UNIX like system.
>
>I'm porting 2.1.1 to QNX6 and got the situation that the module 'os' could not
>be be found with 'import os'
>
>After some hacking with DDD .. I found out that the pathes used by the search
>algorithm of import.c has nothing to do with the directory structure of the UNIX
>distribution of Python 2.1.1 =:-/

I'm not sure you really understand the normal layout of a Unix directory
structure.  In Unix, you never install a product in the root of a
filesystem.  The root is kept as simple as possible:  /usr, /home, /etc,
/var, /boot, /tmp, and little else.  The various files that make up a
product get spread around.  Binaries go into a global binary directory.
Libraries go into a global library directory.  Configuration files go into
yet another central directory.

When you install Python in a Unix-like system, you specify a top-level
"prefix".  This is usually either /usr or /usr/local.  The Python binary is
then installed in $prefix/bin.  The modules are installed in
$prefix/lib/python-2.1 (that is, only the first two digits of the version
are used to make the library path).

>I have installed Python in the root directory and set PYTHONHOME/PYTHONPATH to
>/Python-2.1.1 -> the path to he library modules is then
>
>                     -> /Python-2.1.1/Lib

What you describe is the way a Windows installation works.  This is NOT how
a Unix installation usually works.

>The search algorithm of import.c is using the following search path sequence:
>
>  "os.so"   -> I don't know why it should make sense to open
>               a shared object with fopen ??
>  "osmodule.so"
>  "os.py"
>  "os.pyc"
>
>  "/Python-2.1.1/os.so" ... os.pyc
>
>  "/Python-2.1.1/lib/python2.1/os.so" ... os.pyc
>                ^^^^^^^^^^^^^^^ who got the idea that this is part of the 
>                                UNIX distribution ??

Well, that's the way it works.
--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list