executing python scripts that are symlinked

Charles Smith cts.private.yahoo at gmail.com
Thu May 16 04:29:54 EDT 2013


On 16 Mai, 10:18, Dave Angel <da... at davea.name> wrote:
> On 05/16/2013 03:48 AM, Charles Smith wrote:
>
> > Hi.
>
> > How can I say, from the cmd line, that python should take my CWD as my
> > CWD, and not the directory where the script actually is?
>
> > I have a python script that works fine when it sits in directory WC,
> > but if I move it out of WC to H and put a symlink from H/script to WC,
> > it doesn't find the packages that are in WC.  Also, if I use the
> > absolute path to H, it won't find them, but I guess I can understand
> > that.
>
> > Someone said on the net that python doesn't know whether a file is
> > real or a symlink, but I think that somehow, python is able to find
> > out where the real file is and treat that as its base of operations.
>
> You'd really better specify your environment - exact OS and Python
> version.  symlink and cwd usually imply a Unix-type system, but cmd is a
> Windows thing.
>
> Then give examples of what your cwd is, what string you're typing at the
> shell prompt, and what's happening.


Well, I'm on a ubuntu platform, running subversion, but I can't commit
this debugging tool into the working copy where I'm using it, so I
maintain it in my home directory.  The tool does use production
packages, though.

So, if I say,

  $ python fapi-test.py

and fapi-test.py really is there, then it works, using the codec
production package.  But if I use a symlink instead, it says

Traceback (most recent call last):
  File "test2", line 1, in <module>
    from codec.support import *
ImportError: No module named codec.support


Python tells me Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)



----------------------------------------------------------
http://www.creative-telcom-solutions.de




More information about the Python-list mailing list