Windows安装miniconda
- 下载
- 安装
- 常用命令
- 配置powershell
- VSCode配置虚拟环境
下载
进入官网 https://www.anaconda.com/download/success
下载windows版本的miniconda Miniconda3-latest-Windows-x86_64.exe
安装
一直点击下一步,可以选择安装路径
配置环境变量,在Path中增加配置
如果执行conda -V
失败,添加环境变量
D:\ProgramData\miniconda3
D:\ProgramData\miniconda3\Library\bin
D:\ProgramData\miniconda3\Scripts
换源
# 不知道有没有用,直接执行了这两行
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
常用命令
conda -V
# 查看虚拟环境列表
conda env list
# 创建虚拟环境
conda create --name py39 python=3.9
# 删除虚拟环境
conda remove --name py39 --all
# 进入虚拟环境
conda activate py39
# 查看python版本
python --version
# 退出虚拟环境
conda deactivate
# 从清华源安装依赖
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
配置powershell
正常安装后cmd可以支持conda activate命令,powershell不支持,但是VSCode默认使用的是powershell终端,所以需要配置一下powershell
# 以管理员身份运行powershell,然后执行命令
conda init powershell
重新打开powershell
无法加载文件 C:\Users\user\Documents\WindowsPowerShell\profile.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参
阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
如果出现上述错误
,解决方法为
# 以管理员身份运行powershell,然后执行命令
# RemoteSigned:允许本地脚本运行,远程脚本需签名。
# CurrentUser:仅影响当前用户,无需管理员权限。
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser# 验证是否生效
Get-ExecutionPolicy -List
VSCode配置虚拟环境
1、安装python插件
2、进入设置
3、选择python环境即可