0

I am using VScode to learn Django. I initially set up a virtual environment with Python 3.9. When I type

python

in Mac's terminal. It displays "python3.9" without any issue.

However, when I type the same command in the terminal embeded in VScode. It shows python2.7 as below. Is it a problem of VScode or the settings?

enter image description here

I am learning Django right now and when I run the command:

python manage.py runserver

It shows the error as below. I doubt that two issues were related, but cannot resolve it. Could anyone help me out? Tons of thanks.

  File "manage.py", line 16
    ) from exc
         ^
SyntaxError: invalid syntax

I also tried command "python3" in VScode's terminal. It shows:

(web_programming) @Huans-MacBook-Pro wiki % python3
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
johnwow
  • 477
  • 1
  • 6
  • 12

1 Answers1

0

You may need to change the Python Intrepreter in VSCode to point to Python 3.9 and see if the runserver error disappears.

See this answer: How do you get Visual Studio Code to use different Python interpreter?

Ram
  • 4,724
  • 2
  • 14
  • 22
  • 1
    This is a wired problem. I restarted VScode and found the problem disappeared...Anyway, thanks all the same. – johnwow Jun 13 '21 at 06:59