Run Python Code In Visual Studio Code
===
##### tags: `Visual Studio Code` `Python`
## Download and Installation Visual Studio Code
1. Download Visual Studio Code
> Offical Download: [https://code.visualstudio.com/](https://code.visualstudio.com/)
2. Open Execution File to start installation process, as below,

3. Keep click 「Next」 to completed installation.
## Download and Installation Python
1. Download Python
> Offical Download: [https://www.python.org/](https://www.python.org/)
2. Open Execution File to start installation process, as below,

3. Chekced 「Add python.exe to PATH」option and click Install Now to go to next step, as below,

4. Waiting Installation, as below,

5. After completed install, you will seen the page ad below,

## Configuration the Visual Studio Code
1. Open the Visual Studio Code, and install the 「Python」 and 「Code Runner」plugins, as below,


2. Open the new blank folder where you want your project locate. Let me put the project on 「C:\Users\User\Desktop\Project\Python\Practice」, as below,

3. Press 「Ctrl + Esc」 shortcut to open the terminal, and input
```
pip install virtualenv
```
to install the package for virtual environment and press enter,

4. Same as previous step, this time input the
```
virtualenv .venv
```
and press enter, if successfully, the terminal will print out message for virtual environment information, and check out your workspace, the 「.venv」 folder is already created, as below,

5. Press 「Ctrl + Shift + P」and input 「select」then click 「Python:Select Interpreter」, the Select Interpreter will propmpt, choose the keywrod of 「venv」 option, as below,


6. Same as previous step, this time input the 「create」and select 「Python:Create Terminal」 option, your terminal will changed as below,


:::danger
If exists any error about can not find or something, could be security cause, before the next step, please open you command as administrator and input the 「Set-ExecutionPolicy RemoteSigned」to change policy, after that, repeat previous step again
:::
7. Create the 「.vs」 folder and 「settings.json」file in the folder, move the file into folder, and take the code in settings.json, as below,
```
{
"code-runner.executorMap": {
"python": "$pythonPath $fullFileName"
}
}
```

8. Create the 「test.py」 to check python really successfully execute in Visual Studio Code, as below,

:::info
You can press 「Ctrl + Alt + N」 to execute the python or click the arrow button on top right side like this,

:::