2

I can run python files in cmd promt and Vscode terminal (cmd prompt). When I try to run any programme with Code runner ("code-runner.runInTerminal": false), I get the following error:

[Running] python "c:\Users\MY PATH INCLUDING WHITESPACE\hello_world.py"
Python was not found but can be installed from the Microsoft Store: https://go.microsoft.com/fwlink?linkID=2082640

Here are the user settings (settings.json) I have tried:

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

"code-runner.executorMap": {
    "python": "$pythonPath $fullFileName",
},

"code-runner.executorMap": {
    "python": "$pythonPath -u $fullFileName",
},

..but I always get the same error.

It seems like the problem could be related to code runner, but could have something to do with the setup of python on my machine.

It could potentially have something to do with the fact I have two python files for the location of python.exe:

(base) C:\>where python
C:\Users\<user_name>\AppData\Local\Continuum\anaconda3\python.exe
C:\Users\<user_name>\AppData\Local\Microsoft\WindowsApps\python.exe

This is the only difference I can think of to another machine where this actually works, but can't be sure.

Any ideas what the issue could be?

2 Answers 2

2

maybe try the following: Change the executormap to:

"code-runner.executorMap": {
    "python": "\"$pythonPath\" $fullFileName",
}

Also you could try to give a concrete python path, maybe create a venv and try there:

"python.pythonPath": "venv/bin/python"
Sign up to request clarification or add additional context in comments.

Comments

1

If your directory tree has spaces - do this:

"code-runner.executorMap": {

    "python": "\"$pythonPath\" -u $fullFileName",
}

This is in the case were the "python.pythonPath": "C:\Users\Documents and Settings\appdata\python\code\something something\script.py"

Spaces in the directory structure will abort the script and you'll get a response something like: "C:\Users\Documents is not a valid directory." So you need the escape character like someone above explained.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.