[Tutor] os.symlink can't find target

Bob Williams linux at barrowhillfarm.org.uk
Mon Feb 24 17:07:55 CET 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

My operating system is Linux (openSUSE 13.1).

I'm trying to create symlinks. The following code:

if pathList[j][-3:] == "mp3":
    linkName1 = pathList[j][0:-3] + "mp3"
    linkName2 = destPath + linkName1[len(sourcePath):]
    print 'Creating link %s -> %s' % (linkName2, pathList[j])
    os.symlink(pathList[j], linkName2)

fails with this error:


Creating link /pollux/music/portable/testing/artists/Death in
June/1995 Rose Clouds Of Holocaust/10 Lifebooks.mp3 ->
/home/bob/music/artists/Death in June/1995 Rose Clouds Of Holocaust/10
Lifebooks.mp3
Traceback (most recent call last):
  File "/home/bob/Documents/scripts/python/flac2mp3.py", line 101, in
<module>
    os.symlink(pathList[j], linkName2)
OSError: [Errno 2] No such file or directory

The same thing happens in ipython, when I type the paths in manually.
I have tried escaping the spaces with '\', but the same error is
generated.

The file "/home/bob/music/artists/Death in June/1995 Rose Clouds Of
Holocaust/10 Lifebooks.mp3" definitely exists.

Thanks,

Bob
- -- 
Bob Williams
System:  Linux 3.11.10-7-desktop
Distro:  openSUSE 13.1 (x86_64) with KDE Development Platform: 4.12.2
Uptime:  12:00pm up 11 days 20:00, 5 users, load average: 0.14, 0.17, 0.22
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlMLblkACgkQ0Sr7eZJrmU4qfACdGc7/U8dN6I/NcyJsHA7ILzcV
Ea4AoIHSbWLkg5eQ1Lo5rN7z0FTse+YM
=+wrZ
-----END PGP SIGNATURE-----


More information about the Tutor mailing list