---
# System prepended metadata

title: Visual Studio Code  Python 環境建立
tags: [python, VS code]

---

## 參考文獻
[VS Code Getting Start](https://code.visualstudio.com/docs/python/python-tutorial)

## Install Visual Studio Code
[VS code](https://code.visualstudio.com/)

## Install Python
1. 下載並安裝[Python](https://www.python.org/downloads/)。
2. 於 Extensions 搜尋 phthon，並安裝以下擴充件。
* Python
* Python Extension Pack

![extensions](https://hackmd.io/_uploads/S11pUAfw0.jpg)

## Install Python package

於 Packages 安裝以下元件
* matplotlib
* control
* numpy 

### 方法一：透過Python Environment Manager安裝
![matplotlib](https://hackmd.io/_uploads/rk9L_RMwC.jpg)

### 方法二：透過終端機下指令安裝

#### 開啟終端機
```
py -3 --version  確認 python 版本
```
![終端機](https://hackmd.io/_uploads/B1M6yQk31l.png)

```
py -m pip install matplotlib
py -m pip install control
py -m pip install numpy
py -m pip install SymPy
py -m pip install Pandas
py -m pip install PyWavelets
py -m pip install pyqtgraph PyQt5
```
![指令](https://hackmd.io/_uploads/BJeGxmyn1x.png)


## New file
選擇 python file
![new file-1](https://hackmd.io/_uploads/SJXk50Mv0.jpg)
![new file-2](https://hackmd.io/_uploads/HyKkqRMwA.jpg)

### Test code

[物聯網高手的自我修練：帶你玩轉樹莓派、Arduino 與ESP32](https://github.com/RealJackYeh/drmaster_iot_master/tree/main)
```
import numpy as np
import matplotlib.pyplot as plt
import control
wc = 2 * np.pi * 5
LPF = control.tf([wc], [1, wc])
w = np.logspace(-1.5,3,200)
phase = control.bode(LPF, w, Hz=True, dB=False, deg=True)
plt.show()
```

### Run code
按下Run Python File後，會跑出波德圖。
![code test1](https://hackmd.io/_uploads/SkI6jRfP0.png)
![code test2](https://hackmd.io/_uploads/BJAM2AzDC.png)







