How to setup Code Runner in Visual Studio Code for Python
I have installed Visual Studio Code 1.23.1 and added extensions - Python, Code Runner.
With Code Runner, now I can see the Run Code symbol (triangle) and on highlighting it, I see the shortcut Ctrl + Alt + N. But when I try to use it to run the code that asks for user input, I can't find a way to provide the input. When I try to enter user input, I get error message "Cannot edit in read-only editor". I think this is because I am missing some configuration part for Code Runner like setting up PATH or some other Workspace settings.
Question: Please assist me in identifying what all configuration will I need to do and how?
I did select "Add Python 3.6 to PATH" while installing Python. I have attached screenshots for reference:
Note: Even now when I right click and select "Run Python File in Terminal" for the same program, I can enter user input fine and get the expected output.
visual-studio-code python-3.6
add a comment |
I have installed Visual Studio Code 1.23.1 and added extensions - Python, Code Runner.
With Code Runner, now I can see the Run Code symbol (triangle) and on highlighting it, I see the shortcut Ctrl + Alt + N. But when I try to use it to run the code that asks for user input, I can't find a way to provide the input. When I try to enter user input, I get error message "Cannot edit in read-only editor". I think this is because I am missing some configuration part for Code Runner like setting up PATH or some other Workspace settings.
Question: Please assist me in identifying what all configuration will I need to do and how?
I did select "Add Python 3.6 to PATH" while installing Python. I have attached screenshots for reference:
Note: Even now when I right click and select "Run Python File in Terminal" for the same program, I can enter user input fine and get the expected output.
visual-studio-code python-3.6
add a comment |
I have installed Visual Studio Code 1.23.1 and added extensions - Python, Code Runner.
With Code Runner, now I can see the Run Code symbol (triangle) and on highlighting it, I see the shortcut Ctrl + Alt + N. But when I try to use it to run the code that asks for user input, I can't find a way to provide the input. When I try to enter user input, I get error message "Cannot edit in read-only editor". I think this is because I am missing some configuration part for Code Runner like setting up PATH or some other Workspace settings.
Question: Please assist me in identifying what all configuration will I need to do and how?
I did select "Add Python 3.6 to PATH" while installing Python. I have attached screenshots for reference:
Note: Even now when I right click and select "Run Python File in Terminal" for the same program, I can enter user input fine and get the expected output.
visual-studio-code python-3.6
I have installed Visual Studio Code 1.23.1 and added extensions - Python, Code Runner.
With Code Runner, now I can see the Run Code symbol (triangle) and on highlighting it, I see the shortcut Ctrl + Alt + N. But when I try to use it to run the code that asks for user input, I can't find a way to provide the input. When I try to enter user input, I get error message "Cannot edit in read-only editor". I think this is because I am missing some configuration part for Code Runner like setting up PATH or some other Workspace settings.
Question: Please assist me in identifying what all configuration will I need to do and how?
I did select "Add Python 3.6 to PATH" while installing Python. I have attached screenshots for reference:
Note: Even now when I right click and select "Run Python File in Terminal" for the same program, I can enter user input fine and get the expected output.
visual-studio-code python-3.6
visual-studio-code python-3.6
asked Jun 4 '18 at 21:47
300300
414718
414718
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can provide input by telling code runner to use the terminal. To do this, there is a setting called code-runner.runInTerminal
, set to false by default, that you can set to true.
There is one more thing that you should watch out for if you are using a windows command line for the terminal like CMD or PowerShell. If your project directory has spaces in it (e.g. C:Example Test) you will get an error. To fix this, you need to add escaped quotation marks ("
) around the directory path variables (normally $dir
or $workspaceRoot
) found under the setting code-runner.executorMap
and code-runner.executorMapByFileExtension
in the user settings.
Thank you Zack. That worked! I had lost this question long time before and didn't expect that it'll get answered. I greatly appreciate your answer. Email notification for this question brought me back here and found your answer.
– 300
Aug 7 '18 at 21:01
add a comment |
Here's another alternative answer, I think more accurate.
Add following settings to your vscode user settings file:
"code-runner.executorMap": {
"python": "$pythonPath -u $fullFileName",
},
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50689210%2fhow-to-setup-code-runner-in-visual-studio-code-for-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can provide input by telling code runner to use the terminal. To do this, there is a setting called code-runner.runInTerminal
, set to false by default, that you can set to true.
There is one more thing that you should watch out for if you are using a windows command line for the terminal like CMD or PowerShell. If your project directory has spaces in it (e.g. C:Example Test) you will get an error. To fix this, you need to add escaped quotation marks ("
) around the directory path variables (normally $dir
or $workspaceRoot
) found under the setting code-runner.executorMap
and code-runner.executorMapByFileExtension
in the user settings.
Thank you Zack. That worked! I had lost this question long time before and didn't expect that it'll get answered. I greatly appreciate your answer. Email notification for this question brought me back here and found your answer.
– 300
Aug 7 '18 at 21:01
add a comment |
You can provide input by telling code runner to use the terminal. To do this, there is a setting called code-runner.runInTerminal
, set to false by default, that you can set to true.
There is one more thing that you should watch out for if you are using a windows command line for the terminal like CMD or PowerShell. If your project directory has spaces in it (e.g. C:Example Test) you will get an error. To fix this, you need to add escaped quotation marks ("
) around the directory path variables (normally $dir
or $workspaceRoot
) found under the setting code-runner.executorMap
and code-runner.executorMapByFileExtension
in the user settings.
Thank you Zack. That worked! I had lost this question long time before and didn't expect that it'll get answered. I greatly appreciate your answer. Email notification for this question brought me back here and found your answer.
– 300
Aug 7 '18 at 21:01
add a comment |
You can provide input by telling code runner to use the terminal. To do this, there is a setting called code-runner.runInTerminal
, set to false by default, that you can set to true.
There is one more thing that you should watch out for if you are using a windows command line for the terminal like CMD or PowerShell. If your project directory has spaces in it (e.g. C:Example Test) you will get an error. To fix this, you need to add escaped quotation marks ("
) around the directory path variables (normally $dir
or $workspaceRoot
) found under the setting code-runner.executorMap
and code-runner.executorMapByFileExtension
in the user settings.
You can provide input by telling code runner to use the terminal. To do this, there is a setting called code-runner.runInTerminal
, set to false by default, that you can set to true.
There is one more thing that you should watch out for if you are using a windows command line for the terminal like CMD or PowerShell. If your project directory has spaces in it (e.g. C:Example Test) you will get an error. To fix this, you need to add escaped quotation marks ("
) around the directory path variables (normally $dir
or $workspaceRoot
) found under the setting code-runner.executorMap
and code-runner.executorMapByFileExtension
in the user settings.
answered Aug 5 '18 at 21:10
Zack JorqueraZack Jorquera
265
265
Thank you Zack. That worked! I had lost this question long time before and didn't expect that it'll get answered. I greatly appreciate your answer. Email notification for this question brought me back here and found your answer.
– 300
Aug 7 '18 at 21:01
add a comment |
Thank you Zack. That worked! I had lost this question long time before and didn't expect that it'll get answered. I greatly appreciate your answer. Email notification for this question brought me back here and found your answer.
– 300
Aug 7 '18 at 21:01
Thank you Zack. That worked! I had lost this question long time before and didn't expect that it'll get answered. I greatly appreciate your answer. Email notification for this question brought me back here and found your answer.
– 300
Aug 7 '18 at 21:01
Thank you Zack. That worked! I had lost this question long time before and didn't expect that it'll get answered. I greatly appreciate your answer. Email notification for this question brought me back here and found your answer.
– 300
Aug 7 '18 at 21:01
add a comment |
Here's another alternative answer, I think more accurate.
Add following settings to your vscode user settings file:
"code-runner.executorMap": {
"python": "$pythonPath -u $fullFileName",
},
add a comment |
Here's another alternative answer, I think more accurate.
Add following settings to your vscode user settings file:
"code-runner.executorMap": {
"python": "$pythonPath -u $fullFileName",
},
add a comment |
Here's another alternative answer, I think more accurate.
Add following settings to your vscode user settings file:
"code-runner.executorMap": {
"python": "$pythonPath -u $fullFileName",
},
Here's another alternative answer, I think more accurate.
Add following settings to your vscode user settings file:
"code-runner.executorMap": {
"python": "$pythonPath -u $fullFileName",
},
answered Nov 21 '18 at 10:21
LukewcnLukewcn
215
215
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50689210%2fhow-to-setup-code-runner-in-visual-studio-code-for-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown