Search code examples
pythontarfile

FileNotFoundError with absolute path when trying to read tarball


I am trying to read from a tar-file but despite specifying the absolute path i get a FileNotFoundError.

This is the relevant portion of code:

1 from pathlib import Path
2
3 testPath = Path("G:/test.tar")
4 tar = tarfile.open(testPath, "r")
5 ...

and the file definitely exists. enter image description here

But what I get is (originating from line 4):

FileNotFoundError: [Errno 2] No such file or directory: 'G:\\test.tar'

(I am using PyCharm btw.) What am I missing? I will gladly provide additional information if needed.


Solution

  • Solution:

    after a recent pc-reset I forgot to change explorer-view to "always show file-type-extension" again which led to me not recognizing that it should have been

    test.tar.gz
    

    as there were only other folders in this directory apart from the file in question. So adjusting my testPath solved that.