Miniconda安装及搭建

发布时间 2023-11-22 14:28:10作者: 别小乔我

Miniconda安装配置

下载Miniconda

Miniconda下载地址

最新版 Miniconda For Windows 下载链接

Windows 安装配置

img

img

修改Powershell执行策略(Windows10+非家庭版需要操作)

开始图标右键单击,选择 Windows PowerShell(终端管理员)

先输入下面的内容,并回车:

Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

出现如下内容后,输入:A,回车:

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution
policy might expose you to the security risks described in the about Execution Policies help
topic at https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): -

最后在 Anaconda Powershell Prompt 中输入:

conda init

Conda更换镜像源

清华大学开源软件镜像站

Anaconda Powershell Prompt 中输入:

conda config --set show_channel_urls yes

然后在 Anaconda Powershell Prompt 中输入:

notepad .condarc # 注意有个小点 "." 在 "condarc" 的前面

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

粘贴上面在镜像站复制的文本,保存文件后关闭

最后在 Anaconda Powershell Prompt 中输入:

conda clean -i # 清除源缓存,以启用镜像源

PyPI更换镜像源

校园网联合镜像站

# 设置 PyPI 镜像源
pip config set global.index-url https://mirrors.cern

复制上述文本后,在 Anaconda Powershell Prompt 中粘贴运行即可。

课程环境搭建

创建与激活CONDA环境

conda环境创建: conda create -n p2s python=3.10

(-n代表创建的环境名称,这里是p2s,并指定Python版本为3.10)

激活conda环境:conda activate p2s

删除某个CONDA环境

退出该环境:conda deactivate

删除整个环境:conda remove -n p2s --all

Pip安装与展示

Pip安装课程所需第三方库:pip install jupyter

在指定文件夹输入:jupyter lab(会自动跳转到浏览器)

结束学习时:Ctrl + C (关闭Jupyter Notebook 服务)