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, ![](https://hackmd.io/_uploads/rksk09Rw3.png) 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, ![](https://hackmd.io/_uploads/HkKEAcCwn.png) 3. Chekced 「Add python.exe to PATH」option and click Install Now to go to next step, as below, ![](https://hackmd.io/_uploads/S1lLkiAPh.png) 4. Waiting Installation, as below, ![](https://hackmd.io/_uploads/BkZ51i0w3.png) 5. After completed install, you will seen the page ad below, ![](https://hackmd.io/_uploads/Hk0n1iCv3.png) ## Configuration the Visual Studio Code 1. Open the Visual Studio Code, and install the 「Python」 and 「Code Runner」plugins, as below, ![](https://hackmd.io/_uploads/SJcMbCRv3.png) ![](https://hackmd.io/_uploads/BJ-H-ACvn.png) 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, ![](https://hackmd.io/_uploads/H1MozARDh.png) 3. Press 「Ctrl + Esc」 shortcut to open the terminal, and input ``` pip install virtualenv ``` to install the package for virtual environment and press enter, ![](https://hackmd.io/_uploads/HyNo70Awn.png) 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, ![](https://hackmd.io/_uploads/rkciNRADn.png) 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, ![](https://hackmd.io/_uploads/B1leLC0v3.png) ![](https://hackmd.io/_uploads/SkdDIR0D2.png) 6. Same as previous step, this time input the 「create」and select 「Python:Create Terminal」 option, your terminal will changed as below, ![](https://hackmd.io/_uploads/ByPoUR0w2.png) ![](https://hackmd.io/_uploads/SkUkvA0vh.png) :::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" } } ``` ![](https://hackmd.io/_uploads/BytKFCAwn.png) 8. Create the 「test.py」 to check python really successfully execute in Visual Studio Code, as below, ![](https://hackmd.io/_uploads/ryVLuC0D2.png) :::info You can press 「Ctrl + Alt + N」 to execute the python or click the arrow button on top right side like this, ![](https://hackmd.io/_uploads/BkOjuCCv3.png) :::