conda activate和conda.bat激活不激活Powershell中的虚拟环境

时间:2020-08-24 23:37:56

标签: python powershell cmd anaconda conda

我一直试图在Windows PowerShell中激活虚拟环境,但没有响应,也没有环境变化。这就是我得到的:

PS C:\> conda activate Capstone
PS C:\> conda.bat activate Capstone
PS C:\> cd users\alexa
PS C:\users\alexa> activate Capstone
PS C:\users\alexa> conda activate Capstone
PS C:\users\alexa> activate.bat Capstone
PS C:\users\alexa> conda.bat activate capstone
PS C:\users\alexa> conda info --envs
# conda environments:
#
base                  *  C:\Anaconda3
Capstone                 C:\Anaconda3\envs\Capstone
env2                     C:\Anaconda3\envs\env2
env3                     C:\Anaconda3\envs\env3
project                  C:\Anaconda3\envs\project
tf2-1                    C:\Anaconda3\envs\tf2-1

PS C:\users\alexa> Get-ExecutionPolicy
AllSigned
PS C:\users\alexa>

关于问题是什么的任何想法?

更新:运行conda init,关闭Powershell,然后重新打开,仍然遇到相同的问题:

PS C:\Users\alexa> conda activate capstone
PS C:\Users\alexa> conda init
no change     C:\Anaconda3\Scripts\conda.exe
no change     C:\Anaconda3\Scripts\conda-env.exe
no change     C:\Anaconda3\Scripts\conda-script.py
no change     C:\Anaconda3\Scripts\conda-env-script.py
no change     C:\Anaconda3\condabin\conda.bat
no change     C:\Anaconda3\Library\bin\conda.bat
no change     C:\Anaconda3\condabin\_conda_activate.bat
no change     C:\Anaconda3\condabin\rename_tmp.bat
no change     C:\Anaconda3\condabin\conda_auto_activate.bat
no change     C:\Anaconda3\condabin\conda_hook.bat
no change     C:\Anaconda3\Scripts\activate.bat
no change     C:\Anaconda3\condabin\activate.bat
no change     C:\Anaconda3\condabin\deactivate.bat
no change     C:\Anaconda3\Scripts\activate
no change     C:\Anaconda3\Scripts\deactivate
no change     C:\Anaconda3\etc\profile.d\conda.sh
no change     C:\Anaconda3\etc\fish\conf.d\conda.fish
no change     C:\Anaconda3\shell\condabin\Conda.psm1
no change     C:\Anaconda3\shell\condabin\conda-hook.ps1
no change     C:\Anaconda3\Lib\site-packages\xontrib\conda.xsh
no change     C:\Anaconda3\etc\profile.d\conda.csh
no change     C:\Users\alexa\Documents\WindowsPowerShell\profile.ps1
no change     HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
No action taken.
PS C:\Users\alexa> conda activate capstone
PS C:\Users\alexa>

1 个答案:

答案 0 :(得分:0)

确保在Powershell上运行了“ conda init”。那应该初始化该外壳以使用conda环境。之后,您可能必须重新打开外壳,然后它才能工作。