Conda无法在Power Shell中激活 [英] Conda not activate in Power Shell
问题描述
我已经在Windows 10笔记本电脑上安装了anaconda.我正在尝试激活名为 pyenv
的Python环境.
首先,我在笔记本电脑中检查 conda env列表
,这是电源外壳上的输出:
PS C:\ Users \ User>conda环境列表#conda环境:#基本* C:\ Users \ User \ Anaconda3pyenv C:\ Users \ User \ Anaconda3 \ envs \ pyenv
然后我激活 pyenv
:
PS C:\ Users \ User>康达激活pyenv
但是我再次检查,它仍然会激活 base
环境:
PS C:\ Users \ User>conda环境列表#conda环境:#基本* C:\ Users \ User \ Anaconda3pyenv C:\ Users \ User \ Anaconda3 \ envs \ pyenv
当我使用Anaconda提示符时,它可以正常工作:
(base)C:\ Users \ User> conda激活pyenv(pyenv)C:\ Users \ User>
有人知道为什么会导致此问题以及如何解决此问题吗?
更新:
运行 conda初始化powershell
:
PS C:\ Users \ User>conda初始化powershell不变C:\ Users \ User \ Anaconda3 \ Scripts \ conda.exe不变C:\ Users \ User \ Anaconda3 \ Scripts \ conda-script.py不变C:\ Users \ User \ Anaconda3 \ Scripts \ conda-env-script.py不变C:\ Users \ User \ Anaconda3 \ condabin \ conda.bat不变C:\ Users \ User \ Anaconda3 \ Library \ bin \ conda.bat不变C:\ Users \ User \ Anaconda3 \ condabin \ _conda_activate.bat不变C:\ Users \ User \ Anaconda3 \ condabin \ rename_tmp.bat不变C:\ Users \ User \ Anaconda3 \ condabin \ conda_hook.bat不变C:\ Users \ User \ Anaconda3 \ Scripts \ activate.bat不变C:\ Users \ User \ Anaconda3 \ condabin \ activate.bat不变C:\ Users \ User \ Anaconda3 \ condabin \ deactivate.bat修改后的C:\ Users \ User \ Anaconda3 \ etc \ profile.d \ conda.sh修改后的C:\ Users \ User \ Anaconda3 \ etc \ fish \ conf.d \ conda.fish不变C:\ Users \ User \ Anaconda3 \ shell \ condabin \ Conda.psm1修改后的C:\ Users \ User \ Anaconda3 \ shell \ condabin \ conda-hook.ps1不变C:\ Users \ User \ Anaconda3 \ Lib \ site-packages \ xontrib \ conda.xsh修改后的C:\ Users \ User \ Anaconda3 \ etc \ profile.d \ conda.csh修改后的C:\ Users \ User \ Documents \ WindowsPowerShell \ profile.ps1
更新2:在使用CMD时有效:
C:\ Users \ User> conda激活pyenv(pyenv)C:\ Users \ User>
过一会儿,当我打开Powershell时,我的Powershell出现了此错误.
.:无法加载文件C:\ Users \ User \ Documents \ WindowsPowerShell \ profile.ps1,因为正在运行的脚本是在此系统上禁用.有关更多信息,请参见about_Execution_Policies,网址为https://go.microsoft.com/fwlink/?LinkID=135170.在第1行:3个字符+.'C:\ Users \ BinoyGhosh \ Documents \ WindowsPowerShell \ profile.ps1'+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo:SecurityError:(:) [],PSSecurityException+ FullyQualifiedErrorId:UnauthorizedAccess
然后我发现了这个
I have already install anaconda on my Windows 10 laptop. I'm trying to activate the Python environment named pyenv
.
First, I check the conda env list
in my laptop, this is the output on the power shell:
PS C:\Users\User> conda env list
# conda environments:
#
base * C:\Users\User\Anaconda3
pyenv C:\Users\User\Anaconda3\envs\pyenv
Then I activate pyenv
:
PS C:\Users\User> conda activate pyenv
But I check again, it still activates base
environment:
PS C:\Users\User> conda env list
# conda environments:
#
base * C:\Users\User\Anaconda3
pyenv C:\Users\User\Anaconda3\envs\pyenv
When I use the Anaconda prompt, it works normally:
(base) C:\Users\User>conda activate pyenv
(pyenv) C:\Users\User>
Does anyone know why it causes this problem and how to fix this?
Update:
Running conda init powershell
:
PS C:\Users\User> conda init powershell
no change C:\Users\User\Anaconda3\Scripts\conda.exe
no change C:\Users\User\Anaconda3\Scripts\conda-script.py
no change C:\Users\User\Anaconda3\Scripts\conda-env-script.py
no change C:\Users\User\Anaconda3\condabin\conda.bat
no change C:\Users\User\Anaconda3\Library\bin\conda.bat
no change C:\Users\User\Anaconda3\condabin\_conda_activate.bat
no change C:\Users\User\Anaconda3\condabin\rename_tmp.bat
no change C:\Users\User\Anaconda3\condabin\conda_hook.bat
no change C:\Users\User\Anaconda3\Scripts\activate.bat
no change C:\Users\User\Anaconda3\condabin\activate.bat
no change C:\Users\User\Anaconda3\condabin\deactivate.bat
modified C:\Users\User\Anaconda3\etc\profile.d\conda.sh
modified C:\Users\User\Anaconda3\etc\fish\conf.d\conda.fish
no change C:\Users\User\Anaconda3\shell\condabin\Conda.psm1
modified C:\Users\User\Anaconda3\shell\condabin\conda-hook.ps1
no change C:\Users\User\Anaconda3\Lib\site-packages\xontrib\conda.xsh
modified C:\Users\User\Anaconda3\etc\profile.d\conda.csh
modified C:\Users\User\Documents\WindowsPowerShell\profile.ps1
Update 2: It works when using CMD:
C:\Users\User>conda activate pyenv
(pyenv) C:\Users\User>
After a while, my Powershell appear this error when I open it.
. : File C:\Users\User\Documents\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
+ . 'C:\Users\BinoyGhosh\Documents\WindowsPowerShell\profile.ps1'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
Then I found this solution.
- Run Powershell as Administrator
- Run this line
set-executionpolicy remotesigned
- Close the terminal
Then it works.
这篇关于Conda无法在Power Shell中激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!