gpt4 book ai didi

python - Conda 未在 Powershell 中激活

转载 作者:行者123 更新时间:2023-12-02 22:14:19 24 4
gpt4 key购买 nike

我已经在我的 Windows 10 笔记本电脑上安装了 anaconda。我正在尝试激活名为 pyenv 的 Python 环境.

首先,我查看 conda env list在我的笔记本电脑中,这是电源 shell 上的输出:

PS C:\Users\User> conda env list
# conda environments:
#
base * C:\Users\User\Anaconda3
pyenv C:\Users\User\Anaconda3\envs\pyenv

然后我激活 pyenv :
PS C:\Users\User> conda activate pyenv

但是我再检查,它仍然激活 base环境:
PS C:\Users\User> conda env list
# conda environments:
#
base * C:\Users\User\Anaconda3
pyenv C:\Users\User\Anaconda3\envs\pyenv

当我使用 Anaconda 提示符时,它正常工作:
(base) C:\Users\User>conda activate pyenv

(pyenv) C:\Users\User>

有谁知道为什么会导致这个问题以及如何解决这个问题?

更新:

运行 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

更新 2:
它在使用 CMD 时有效:
C:\Users\User>conda activate pyenv

(pyenv) C:\Users\User>

最佳答案

过了一会儿,当我打开它时,我的 Powershell 出现此错误。

. : 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
然后我找到了这个 solution .
  • 以管理员身份运行 Powershell
  • 运行此行 set-executionpolicy remotesigned
  • 关闭终端

  • 然后它起作用了。
    enter image description here

    关于python - Conda 未在 Powershell 中激活,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62082873/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com