Skip to content Skip to sidebar Skip to footer

Python Script Can't Find File When Opening With Vs Code, But Works Ok With Terminal

I've got a python script which works with some files using normal with open('input.txt', 'r') as file: And there is input.txt in the same folder. Problem is, when I launch it with

Solution 1:

In the launch config change the CWD to the folder

{
    "version": "0.2.0",
    "configurations": [
        {
            ....,
            "cwd" : "${workspaceFolder}/${relativeFileDirname}"
        }
    ]
}

Solution 2:

Your terminal in vscode is at this location: "~/bioinformatics-algorithms"

This is were the terminal executes the python code and search for the files. You have to change the terminal location to "~/bioinformatics-algorithms/1.3/PatternMatcher".

Post a Comment for "Python Script Can't Find File When Opening With Vs Code, But Works Ok With Terminal"