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>
The python extension officially does not support powershell for activating conda environments “Note: conda environments cannot be automatically activated in the integrated terminal if PowerShell is set as the integrated shell. See Integrated terminal - Configuration for how to change the shell.” - Using python environments in VSCode
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'.
For those who are still stuck-> Go to windows search -> Search for "Anaconda Powershell Prompt" -> With the opened Powershell, prompt type conda init powershell and hit enter-> type conda and hit enter in the same poweshell prompt to check if it worked. Note: I used miniconda and the flow works.
So I mass tested Anaconda installation and conda init in a class of approx. twenty students and everything works fine as long as one runs in the elevated powershell. Otherwise one gets the aforementionend permission error.
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.
set-executionpolicy remotesigned
Then it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With