Python/C and PYTHONPATH

Tero Pihlajakoski tepihlaj at NOpaju.SPAMoulu.fi
Mon Jan 5 13:59:36 CET 2004


Hi,

I've been experimenting on embedding Python to a C software, and ran into
a little problem with PYTHONPATH (I'm running on linux). Here's the deal:

When trying to call PyImport_Import("xyz"), Python returns an error "No
module named xyz". The problem _seems_ to be that I had no PYTHONPATH
variable defined (though python-shell works ok regardless), since the
following in bash helps:

<try, no go>
PYTHONPATH=
export PYTHONPATH
<try, works ok>

I'm not defining anything as the PATH, and now it works. Why doesn't it
look from "." without a dummy PYTHONPATH? Or is this actually a bug fixed
in a newer release (running 2.3.?)?

What is the "official" way to solve this? PySetProgramName()? Shell
script?

Thanks, 
  - Tero

-- 




More information about the Python-list mailing list