How to setup Code Runner in Visual Studio Code for Python












0















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:



ExecutionErrorExecutionError



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.
ExecutionWorking










share|improve this question



























    0















    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:



    ExecutionErrorExecutionError



    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.
    ExecutionWorking










    share|improve this question

























      0












      0








      0


      1






      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:



      ExecutionErrorExecutionError



      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.
      ExecutionWorking










      share|improve this question














      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:



      ExecutionErrorExecutionError



      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.
      ExecutionWorking







      visual-studio-code python-3.6






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 4 '18 at 21:47









      300300

      414718




      414718
























          2 Answers
          2






          active

          oldest

          votes


















          1














          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.






          share|improve this answer
























          • 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



















          1














          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",
          },





          share|improve this answer























            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            1














            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.






            share|improve this answer
























            • 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
















            1














            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.






            share|improve this answer
























            • 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














            1












            1








            1







            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.






            share|improve this answer













            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.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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



















            • 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













            1














            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",
            },





            share|improve this answer




























              1














              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",
              },





              share|improve this answer


























                1












                1








                1







                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",
                },





                share|improve this answer













                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",
                },






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 21 '18 at 10:21









                LukewcnLukewcn

                215




                215






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    這個網誌中的熱門文章

                    Xamarin.form Move up view when keyboard appear

                    Post-Redirect-Get with Spring WebFlux and Thymeleaf

                    Anylogic : not able to use stopDelay()