Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python path in VSCode: The system cannot find the path specified

After installing VSCode (I already have python 2.7 on my machine), I tried to run a simple script on Windows 10 and got this error:

[Running] /usr/bin/env python "c:\Users\jim\Dropbox\projects\python\myproject\main.py" The system cannot find the path specified.

So I tried to edit these settings:

enter image description here

And also these:

enter image description here

but I'm still getting this error.

like image 429
danny kob Avatar asked Dec 01 '22 14:12

danny kob


1 Answers

It looks like you're using the Code Runner extension to run your code, and it's doing /usr/bin/env python instead of just python. Go into your User Settings and add the following:

"code-runner.executorMap": {
    "python": "python",
}

Also double-check that your python script doesn't start with the shebang #!/usr/bin/env python, as that could also be causing the behaviour you're experiencing.

EDIT: Turns out there's a code-runner.respectShebang setting for the Code Runner extension that defaults to true, but can be set to false to allow you to keep the shebang in the script but not use it when running the code via Code Runner:

{
    "code-runner.respectShebang": false
}
like image 116
Mihai Chelaru Avatar answered Dec 05 '22 12:12

Mihai Chelaru