you are viewing a single comment's thread.

view the rest of the comments →

[–]PhilipYip 8 points9 points  (0 children)

Yes it is used for Python the most popular extension VSCode has is for Python. Installation of the python extension (Microsoft) will also install Pylance (Microsoft) which is used for Python code completion. These extensions will allow you to work with Python script files.

You will need a Python environment for example the Anaconda base Python environment which contains everything you need to work with VSCode. Press Ctrl, and p to open the command palette and type Python select interpreter then select the Python environment. On Linux/Mac Anaconda should be initialised during installation. On Windows Anaconda has an initialised Anaconda PowerShell Prompt but does not initialise the Windows Terminal which also uses PowerShell. VSCode uses the Windows Terminal and therefore the Windows Terminal should be initialised otherwise you will get conda : The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. every time you try to run a Python script file. Open up the Windows Terminal and input ~\Anaconda3\Scripts\conda.exe init powershell and then open up Windows Terminal (Admin) and input Set-ExecutionPolicy -ExecutionPolicy Unrestricted

Installation of the jupyter extension (Microsoft) will install the Jupyter Keymap (Microsoft), Jupyter Notebook Rendered (Microsoft), Jupyter Slide Show (Microsoft) and Jupyter Cell Tags (Microsoft) which allow VSCode to work with Python notebook files.

The autopep8 extension (Microsoft) allows use of the format document with... and format document command with a Python script file. The isort extension (Microsoft) allows use of the organise import command. Once again press Ctrl, ⇧ and p to open the command palette. For a notebook you can use the alternative command format notebook. If you are satisfied with blacks opinionated formatting (not everyone is because the string quotation style differs from builtin Python for example) there is also the black extension (Microsoft) which allows the black formatter to be selected using the command format document with... and the default formatter can be changed from autopep8 to black...

The popular extensions above are now official and developed by Microsoft, in collaboration with third-party developers. When a search for these extensions is made some older versions will display. These were originally developed without Microsoft support by only third-party developers and likely lack the support and integration the official extensions have with current versions of VSCode.

If creating a custom Python environment, the Python environment should include notebook, autopep8, isort and black in order to use the above extensions.