Visual Studio code에서 빨간색 글씨로 위와 같은 에러가 떴다.
이 시스템에서 스크립트를 실행할 수 없으므로 C:\Users\RWIZ\Documents\WindowsPowerShell\profile.ps1 파일을 로드할 수 없습니다. 자세한 내용은 abou
t_Execution_Policies(https://go.microsoft.com/fwlink/?LinkID=135170)를 참조하십시오.
위치 줄:1 문자:3
이 에러는, Anaconda 설치 후 conda 명령어를 vscode terminal에서 실행하려고 할 때 뜬다.
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
conda init <SHELL 이름>
을 실행해야 터미널 킬 때마다 번거롭게 가상환경을 매번 conda activate <가상환경이름>
을 하지 않아도 된다.
그런데 나처럼 에러가 뜬다면, 아래와 같이 해결해야 한다.
> get-ExecutionPolicy
명령어로 실행 권한 상태를 확인해보면, 아마 "Restricted"라고 나올 것이다.
Restricted : default설정값으로, 스크립트 파일을 실행할 수 없다.
AllSigned : 신뢰할 수 있는(서명된) 스크립트 파일만 실행할 수 있다.
RemoteSigned : 로컬에서 본인이 생성한 스크립트와, 신뢰할 수 있는(서명된) 스크립트 파일 실행할 수 있다.
Unrestricted : 모든 스크립트 실행가능하다.
ByPass : 경고/차단 없이 모든 것을 실행가능하도록한다.
Undefined : 권한을 설정하지 않았다.
😣 이게 vscode에서 에러 발생 원인이었다 !!!
> Set-ExecutionPolicy RemoteSigned
명령어를 실행하여 권한을 "Restricted"에서 "RemoteSigned"로 바꾸어 스크립트를 다른 곳에서도 실행할 수 있도록 변경해준다.
잘 바뀐 것을 확인할 수 있다.
Powershell로 원하는 것이 잘 실행된다.