I run a python script in vscode but the value in the output tab does not match the value in the terminal
See original GitHub issueEnvironment data
- VS Code version: 1.38
- Extension version (available under the Extensions sidebar): XXX
- OS and version: windows 8
- Python3 version (& distribution if applicable, e.g. Anaconda): 3.6.8
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): XXX
- Relevant/affected Python packages and their versions: XXX
- Jedi or Language Server? (i.e. what is
"python.jediEnabled"
set to; more info #3977): XXX
Expected behaviour
terminal and output must print 1.5
Actual behaviour
Output tab prints a 0 and terminal value prints a one
Steps to reproduce:
Run this code
class Solution:
def lt(self, p, q, h,start):
if(q==0 and h ==start):
if(0<=p<=1):
return p
if(p>1):
return 1
if(q<0 or p<0):
return 0
a=self.lt((p-1)/2,q-1,h,start)
b= self.lt((p-1)/2,q-1,h,start+1)
return a+b
a=Solution()
print(a.lt(6,2,1,0))
Logs
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
XXX
Output from Console
under the Developer Tools
panel (toggle Developer Tools on under Help
; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging
)
XXX
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
Visual Studio Code is not showing the ouput of Python
Save this file, then go to the Terminal tab at the bottom and type python hello.py and press Enter. This should run the...
Read more >Debugging configurations for Python apps in Visual Studio Code
Switch to the Run and Debug view (Ctrl+Shift+D), select the appropriate configuration from the debugger dropdown list, and start the debugger. The debugger ......
Read more >Editing Python in Visual Studio Code
is a simple way to take whatever code is selected, or the code on the current line if there is no selection, and...
Read more >Get Started Tutorial for Python in Visual Studio Code
Linux/macOS: open a Terminal Window and type the following command: python3 --version · Windows: open a command prompt and run the following command:...
Read more >Tasks in Visual Studio Code
Possible values are: shared - The terminal is shared and the output of other task runs are added to the same terminal. dedicated...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I updated the issue template
On Wed, Sep 11, 2019 at 5:33 PM Kim-Adeline Miguel notifications@github.com wrote:
First, please note that the Code Runner extension isn’t related to the Python extension for VS Code.
It looks like you have multiple versions of Python installed, so if you run
python
in a terminal window without an active virtual environment it will start the interpreter for Python 2.7, and to get Python 3.X you would have to runpython3
.Manually running
python <yourfile.py>
returns 0, while runningpython3 <yourfile.py
returns 1.5.If you modify the
code-runner.executorMap
setting for the Code Runner extension you will see that it callspython -u
for Python files and notpython3 -u
.If you look at the Configuration section for the Code Runner extension, they mention this custom parameter:
which you could use in
code-runner.executorMap
.Related upstream issue: https://github.com/formulahendry/vscode-code-runner/issues/524.