skip to Main Content

I am a beginner in Python. I used VS Code as a text editor.

While running a code the command started with python -u and I got an error. But I got my expected result in the terminal tab when I started my code with python3. So how to change Python’s version in the output panel by default?

OUTPUT PANEL SHOWING AN ERROR

2

Answers


    1. Open the terminal.
    2. Lead to ~/.bash_profile.
    3. Add the line alias python='python3'

    BTW, according to your picture, I guessed that you didn’t install Python and Pylance extensions. You can install them and read document about python in VSCode for more details.

    Login or Signup to reply.
  1. python in mac usually points to python2, but currently the system no longer pre-installs python2, so you need to point python to python3.

    Execute the following command in terminal

    echo "alias python=/usr/bin/python3" >> ~/.zshrc
    

    Also you are using Code Runner to execute the script which is not the recommended way. You should use Python extensions for more features and better experience.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search