Limetime's TimeLine
article thumbnail
반응형

cmd에서는 conda activate 명령이 잘 작동하여 환경 전환이 자유롭게 일어나는데 PowerShell에서는 이상하게 전환이 안된다. 오류나 에러가 뜨는 것도 아니다.

conda activate 명령어를 실행해도 환경은 바뀌지 않고 그대로다.

 

CMD와 달리 PowerShell은 권한 문제로 인하여 conda 명령의 일부만 작동하고 나머지는 에러도 내지 않는 그냥 작동 불능 상태이다.

 

Powershell에서 conda activate가 작동이 되지 않는 문제 해결하기

CMD에서는 정상적으로 가상환경 전환이 가능하지만, Powershell에서는 권한문제로 정상적으로 작동하지 않아 conda 명령어가 작동하지 않는것은 물론 env에 진입이 불가능한 현상이 있습니다. >>> impor

3billion-ly.tistory.com

반응형

해결책을 찾긴 했으나...

진전이 없었다.

 

PowerShell을 관리자 권한으로 실행해준 뒤 아래 명령어 작업을 진행했다.

# 콘다 패키지 관리자 및 모든 하위 패키지 업데이트
conda update --all

# 콘다 파워쉘 이니셜라이징 (관리자 권한으로 실행해야함!!)
conda init powershell

# 파워쉘 권한 변경(파워쉘에서만 입력가능) (관리자 권한으로 실행하셈!) (A를 입력하면 된다.)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

conda update --all은 base 패키지도 다 업데이트 하는 것 같았다.

나머지를 다 해줬는데도 결국 해결이 되지 않았다.

원인은 아마도 경로에 한글이 들어가서 그런 것 같다.

 

----추가----

 

How to activate conda environment from powershell?

Version Anaconda 4.8.3 What I cannot do: I can't activate any environment from powershell. conda activate base What I can do: conda env list conda create -n xxx conda remove -n xxx I have tried m...

stackoverflow.com

=> 원인은 역시 경로에 한글이 들어가는 것이 문제였다!! <=

\WindowsPowerShell\profile.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3

conda init powershell할 때 원래 C:\Users\사용자명\Documents\WindowsPowerShell 폴더에 profile.ps1 이라는 파일이 생기고 여기에 init한 정보가 저장될텐데 이게 이상하게 꼬여버린 것이다.

역시 profile.ps1 파일을 못찾는게 큰 이유였다.

반응형

보면 한글 이름을 ����� 으로 인식하곤 새로운 폴더를 생성해버린다. 이러니 당연히 안되는게 맞지... ㅠㅠ

엉뚱한 곳에 profile.ps1을 생성해버리는 것이다.


2024.01.19 해결

한글 계정으로도 가능하다.

1. C드라이브에 'WindowsPowerShell' 폴더를 생성하기

 

2. WindowsPowerShell 폴더 안에 'profile.ps1' 파일 생성하고 값 입력하기

<profile.ps1의 내용>

#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
If (Test-Path "anaconda3가 설치된 경로\Scripts\conda.exe") {
    (& "anaconda3가 설치된 경로\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | ?{$_} | Invoke-Expression
}
#endregion

------------------------------------------------------------------------------------------------
<필자의 경우>
#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
If (Test-Path "C:\anaconda3\Scripts\conda.exe") {
    (& "C:\anaconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | ?{$_} | Invoke-Expression
}
#endregion

 

3. 레지스트리에 Powershell 폴더 영구 등록하기

컴퓨터\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

'Personal 항목 클릭'

'WindowsPowershellShell/profile.ps1'이 있는 폴더를 'Personal' 값으로 주기

 

4. powershell을 관리자 권한으로 실행하여 'Set-ExecutionPolicy -ExecutionPolicy RemoteSigned' 명령주기

끝...

반응형
profile

Limetime's TimeLine

@Limetime

포스팅이 좋았다면 "공감❤️" 또는 "구독👍🏻" 해주세요!