Python is unable to open my simlinked file. I made sure the file exists and I can access it. I was under the impression that symlinks are resolved on the OS level so Python would never know about it.
therold@therold:~/Programming/ML/deeptank/dataset/inc (master)$ ls -lisa /Users/therold/Programming/ML/deeptank/dataset/inc/training/tanks/matilda-iv_689.png
7870541 8 lrwxr-xr-x 1 therold staff 46 13 Mai 16:44 /Users/therold/Programming/ML/deeptank/dataset/inc/training/tanks/matilda-iv_689.png -> ../training_data/matilda-iv/matilda-iv_689.png
OSX is clearly able resolve the symlinked image file. However the Python open()
method fails me:
therold@therold:~/Programming/ML/deeptank/dataset/inc (master)$ python
Python 2.7.10 (default, Sep 23 2015, 04:34:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
>>> open("/Users/therold/Programming/ML/deeptank/dataset/inc/training/tanks/matilda-iv_689.png")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: '/Users/therold/Programming/ML/deeptank/dataset/inc/training/tanks/matilda-iv_689.png'
>>>
Any ideas what I am doing wrong? Help is much appreciated.
ls -lL /Users/therold/Programming/ML/deeptank/dataset/inc/training/tanks/matilda-iv_689.png
to confirm the existence of the file. – ErythroblastNo such file or directory
It seems the symlink is broken after all. I still don't understand why I was able to resolve it in thels
statement in my question. – Venusls
statement in your question.ls -l
simply displays the linked-to path.ls -lL
attempts to resolve the link. – Erythroblast