가상 환경 활성화
python과 Visual Studio Code for Mac을 기본적으로 설치하고 terminal을 실행한다. 원하는 폴더에 들어가서
python3 -m venv (filename)
명령어를 통해서 python 폴더를 생성한다.
이 후 bin파일 안에서 source ./activate
를 통해 가상 환경을 활성화할 수 있고 deactivate
를 통해서 다시 비활성화할 수 있다.
VScode Interpreter 설정
VScode를 열고 command + shift + p
를 통해서 명령 팔레트를 실행하고
Python: Select Interpreter를 눌러서 Interpreter를 설정한다.
Interpreter은 설치한 python의 원하는 버전으로 지정하면 된다.
debug
Tasks: Configure Task를 누르면 tasks.json파일이 생성된다.
이 후 tasks.json의 내용을 아래와 같이 채워넣으면
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Project Label",
"type": "shell",
"command": "python3",
"args": [
"${file}"
],
"presentation": {
"reveal": "always",
"panel": "new"
},
"options": {
"env": {
"PYTHONIOENCODING": "UTF-8"
}
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
command + shift + b
를 통해서 간편하게 실행할 수 있다.