Visual Studio Code (VScode)에서 Python 실행환경 세팅
#1. 당연히 VScode 설치
https://code.visualstudio.com/
Visual Studio Code - Code Editing. Redefined
Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.
code.visualstudio.com
#2. 파이썬 설치를 위한 Chocolatey(choco) 설치
먼저 cmd 창을 관리자 권한으로 실행한다.
그 다음에 아래와 같은 명령어를 입력한다.
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command " [System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Chocolatey - The package manager for Windows
Chocolatey is software management automation for Windows that wraps installers, executables, zips, and scripts into compiled packages. Chocolatey integrates w/SCCM, Puppet, Chef, etc. Chocolatey is trusted by businesses to manage software deployments.
chocolatey.org
#3. 파이썬 설치
cmd 창을 관리자 권한으로 실행한다.
그 다음에 아래와 같은 명령어를 입력한다.
choco install python -y
설치가 완료되면 버전 확인을 통해서 제대로 설치되었는지 확인해본다.
python --version
# Python 3.10.1
#4. VScode내 세팅
Extensions 탭에 들어가서 Python 관련 Extension을 설치해준다. 가장 중요한건 Python
그 이외에도 여러가지 있으니 본인이 원하는 만큼 설치해준다. 설치겸 찾아보니 아래와 같은 Extension이 있어서 설치
#5. 실행 테스트
적당한 test용 python 파일을 만든다.
print("Hello Python")
그 다음에 Run > Run Without Debugging을 누른다. 단축키 (Ctrl + F5)
위와 같이 실행된다.
#6. 추가 체크 내용
대부분 안되는경우는 Python 컴파일러가 제대로 연결이 안 되어있을 확률이 높다.
View > Command Palette (단축키 Ctrl + Shift + P) 실행
본인이 설치한 Python의 경로를 넣어주면 된다.