Python Forum
VS Code from start
Thread Rating:
  • 3 Vote(s) - 3.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VS Code from start
#1
This will be about VS Code.
Will take if start,so get Python up running with some advice that make it easy to run code.
I has quick review before to look at here.
That also show some basic stuff about the editor.

Quote:Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux
They have but a lot of resources to make Python work well in there editor.
Like hire @don Jayamanne the maker of Python Extension for VS Code.
VS Code is a multi-language editor that is same league as Atom and Sublime Text.

Start
Should make sure that python and pip work from command line,before install.
This will make setup in editor and stuff like virtual environment easier.
Python 3.6/3.7 and pip installation under Windows
C:\code
λ python -V
Python 3.7.0

C:\code
λ pip -V
pip 18.0 from c:\python37\lib\site-packages\pip (python 3.7)
Linux if python3 point to Python 3 use that in setup later.

Install
Install choose user installer.

After install the first ting to do is install needed Extension.
Here list of needed and some useful Extension.
Can also use Marketplace to find and install extensions.
  • python
  • Python Extension Pack
  • Code Runner
  • vscode-icons
  • Bracket Pair Colorizer
  • highlight-icemode
  • PlasticAB # My Theme

Setup
Now gone do some setup to Code runner and install some stuff so PEP-8 format of code and linter work.
[Image: 7XwKWx.jpg]
Search in setting code-runner.executorMap
Click on the pen so on right side(user setting) so this is the result.
"php": "php",
"python": "$pythonPath $fullFileName",
"perl": "perl",
This make Code runner button always use Python interpreter down in left corner(see image).
Can click on to change to other python interpreter installed like eg Anaconda.
Search setting code-runner.runInTerminal and set it to True,make stuff like input() work in Code runner.

Install of modules command line for format code and linter.
pip install autopep8 yapf black
pip install pylint
Search setting python.formatting.provider to choose formater.
Command platte search pylint to turn on/off,it can be annoying to have on alle time.

Run Code
[Image: lPKP5X.jpg]

Start VS Code from any folder,eg for a virtual environment
With code . from command line in any folder will open files in that folder in VS Code.
Example with virtual environment that build into Python venv
# Make
E:\div_code
λ python -m venv my_env

# cd in
E:\div_code
λ cd my_env

# Activate
E:\div_code\my_env
λ E:\div_code\my_env\Scripts\Activate

# Test pip
(my_env) E:\div_code\my_env
λ pip -V
pip 10.0.1 from e:\div_code\my_env\lib\site-packages\pip (python 3.7

# Install required package 
(my_env) E:\div_code\my_env
λ pip install requests
Collecting requests

# Start VS Code
(my_env) E:\div_code\my_env
λ code .
See now that it automatically find Python interpreter in virtual environment.
So push run button it will use Python version in virtual environment.
[Image: 51qWOg.jpg]

This was basic setup will post more stuff later.
Reply


Messages In This Thread
VS Code from start - by snippsat - Aug-16-2018, 01:34 PM
RE: VS Code from start - by snippsat - Aug-18-2018, 08:49 PM
RE: VS Code from start - by snippsat - Aug-24-2018, 10:23 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020