vscode-code-runner icon indicating copy to clipboard operation
vscode-code-runner copied to clipboard

[Bug] print(k, end=' ') in python3

Open LongJinhe-coder opened this issue 5 years ago • 1 comments

  • VS Code Version:1.41.1
  • OS Version:linux x64 5.0.0-13-generic
  • Code Runner Version:0.9.15

Describe the bug it shows SyntaxError: invalid syntax when i click Run Code but not when debugging or other ways to run code To Reproduce Steps to reproduce the behavior:

  1. python3 print(k, end=" "),when i click Run Code,it will show
    print(k, end=' ') ^ SyntaxError: invalid syntax
  2. but it go succsessfully when i debug or run the code without using Code Runner, and it also succeed in pycharm.

Actual behavior SyntaxError: invalid syntax

Expected behavior run successfully Screenshots If applicable, add screenshots to help explain your problem.

LongJinhe-coder avatar Dec 23 '19 05:12 LongJinhe-coder

I hope this issue is solved

But in case it isn't

This extension runs python -u for python files, while it is the default command for python 2

So in order to fix it, go to your settings.json of vs code and under the property code-runner.executorMap, find the command for python and change it from python -u to python3 -u

Similar to the image given below

image

YASHBRO avatar May 14 '22 08:05 YASHBRO