python - conda init powershell没有效果
问题描述
我在我的 Windows 笔记本电脑上安装了 Anaconda3 并尝试在 powershell 中使用 conda activate 命令,以便我可以在 VS Code 中将 conda env 用于 Jupyter Notebook。但问题是这样的:
- 将 Conda 添加到 Environment-PATH
- 我在 conda 提示符下执行了conda init powershell并在战后关闭了它
- 打开 powershell 并执行set-executionpolicy remotesigned
- 然后我重新启动了电脑
- 尽管此时它应该可以工作,但在 powershell中执行conda activate base时我仍然收到以下消息:
CommandNotFoundError:您的 shell 未正确配置为使用“conda activate”。如果使用批处理脚本中的“conda activate”,请将您的调用更改为“CALL conda.bat activate”。要初始化你的 shell,运行 conda init <SHELL_NAME> 当前支持的 shell 是:
- 重击
- 命令文件
- 鱼
- tcsh
- 呸呸呸
- zsh
- 电源外壳
有关更多信息和选项,请参阅“conda init --help”。重要提示:您可能需要在运行“conda init”后关闭并重新启动 shell。
解决方案
我注意到您的 powershell 可以conda init
成功执行。
2.我在conda提示符下执行了conda init powershell,然后关闭了
通常,此命令将编辑此帐户的 powershell 启动配置文件,该文件位于C:\Users\[YOUR_ACCOUNT_NAME]\Documents\WindowsPowerShell\profile.ps1
. 请确保编辑后的文件在您的个人文件夹中包含如下代码:
#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
(& "C:\ProgramData\Miniconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Invoke-Expression
#endregion
有时,当您的帐户名包含非ASCII字符时,powershell正在使用的代码页可能会导致乱码,从而导致在profile.ps1
乱码路径中进行编辑。只需将其复制到您的真实帐户路径中,如上所示。
推荐阅读
- excel - 即使存在多个实例,如何在excel的列中搜索连续数字的特定数据
- javascript - 将类添加到 Wordpress 上的切换复选框父级
- html - 某些 unicode 图标未保存并正确显示
- azure - 如何在 azure devops 扩展 api 中获取当前发布上下文
- javascript - 带复选框的表单提交
- c# - PRISM 7 log4net 集成
- netlogo - Netlogo : 使用 Levelspace 将值从子模型导入父模型
- c# - 卸载视图时调用 LoadedCommand
- elasticsearch - ElasticSearch 连接设置
- python - 简单的 Python 类不显示/打印任何东西