0

I'm new to using VS Code and wish to use this with Python (which I am new to as well)

Followed all the install instructions of both Python and Visual Studio as well as installing the Python Extension.

Checking Terminal and this confirms that Python is installed and the extension is installed in VS code.

However, when I try to run a simple script on Python, I get the below error.

VS Code Error

Here is my terminal to show Python Installed Terminal Script

I have researched extensively and watch multiple videos and can't see where I am going wrong.

I read something about updating PATH and BASH profile, but I don't really have the knowledge in this space.

Any help would be greatly appreciated.

Edit, adding in code

Python Code

5
  • 1
    Can you attach the top line of your python script? Probably it calls python and not python3, which is what you have installed. Change it to python3 and see if that works. I don't know if this is duplicate but the following answer should be helpful: stackoverflow.com/questions/6908143/… Commented Jan 9, 2024 at 16:46
  • I've edited the post, just running a simple print function. Do I need to save my file as tes.py3? Commented Jan 9, 2024 at 16:58
  • Did you setup the interpreter as described at stackoverflow.com/questions/47602151/… ? Commented Jan 9, 2024 at 17:02
  • It looks like you're using the Code Runner extension. Are you aware it's independent from the Python extension? Have you configured it? What research have you done exactly? Have you tried running your code with the Python extension? Commented Jan 9, 2024 at 17:05
  • @wjandrea yeah i installed Code Runner as part of steps I followed on a couple of videos, are you suggesting that I remove it? *It is working now, turns out that it was Code Runner Extension that was causing the issue, I have uninstalled this re-ran the script and is now working. Commented Jan 9, 2024 at 17:12

1 Answer 1

1

For your original problem, you could open your User settings and search for "code-runner.executorMap".

Set "python": "python3 -u", in this setting.

By the way, I suggest you using Run Python File button which provided by Microsoft Python extension.

Sign up to request clarification or add additional context in comments.

1 Comment

Perfect thank you, I was just hitting the run button not realising that it was defaulted to Code Runner and not Python. Clicked the little drop down next to it and this has solved the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.