Double symlinking breaks module import

Csaba Henk tphhec01 at
Sun Aug 24 11:16:27 CEST 2003

In article <ItW1b.912$Jh2.38 at>, Andrew Dalke wrote:
> Csaba Henk:
>> But
>> if I create another symlink ->, and then I invoke
>>, I get compliances that mymod is not found.
>> Is it a bug or policy?
> Python uses the normal file open functions, which automatically
> follow links.  It doesn't build in the link following code itself.
> I suspect your symlink points to the wrong place.  Can you
> cat the file?

The symlink can't be wrong because the python program itself (to which the
symlinks refer) starts up; it just doesn't find the module. This question is
related to importing modules, and the list of dirs in which the module
seeked is a Python internal, so it does not depend only on file functions.
How symlinking affect the module search path? As I now, modules seeked in
the current dir and standard places. If I invoke the prog via a symlink, the
current dir is not the same as for the program (where the module resides
also), still the module is found somehow. But not if two symlinks used.

Btw, the program with which I have this program, is sketch. Sketch has and the module Sketch in <prefix>/lib/sketch-0.6.15/. It's usually
invoked via the symlink 
<prefix>/bin/sketch -> ../lib/sketch-0.6.15/ My problem occured
when I wanted to started sketch via another symlink pointing to
<prefix>/bin/sketch. You can test my report by installing sketch. is the following code:

import sys

if sys.version < '1.5.1':
    sys.stderr.write("Sorry, Sketch requires at least Python 1.5.1\n")

import Sketch

Sketch.config.sketch_command = sys.argv[0]



Set theory is the LSD of mathematics

More information about the Python-list mailing list