PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, May 14, 2022

[FIXED] How to run python3 code in VSCode? /bin/sh: 1: python: not found

 May 14, 2022     python, python-3.x, ubuntu, visual-studio-code     No comments   

Issue

I'm trying to run a python file in VSCode using python3.

I know I can fix by simply setting to run using integrated terminal like it says in the microsoft vscode tutorial on python. However, I would like the program to print in the output tab and not take up the terminal window.

enter image description here

The standard coder runner launch.json looks like this;

"version": "0.2.0",
"configurations": [
    {
        "name": "Python: Current File",
        "type": "python",
        "request": "launch",
        "program": "${file}",
        "console": "integratedTerminal"
    }
]

I've tried to set my python path in VSCode in settings.json

...
"python.pythonPath": "python3",
"code-runner.executorMap": {
    "python3": "/usr/bin/python3"
}

I've also set an alias for python -> python3 (as my ubuntu 20.04 doesn't come with python2 anymore)

alias python="python3"

However, I keep getting the above error. Any Ideas?


Solution

Nearly had it. This code

"python.pythonPath": "python3",
"code-runner.executorMap": {
    "python3": "/usr/bin/python3"
}

should be

"python.pythonPath": "python3",
"code-runner.executorMap": {
    "python": "/usr/bin/python3"
}

(The difference is at the beginning of line 3)



Answered By - Kaigo
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing