使用轻量级Anaconda--Miniconda
步骤:
- 下载源:清华镜像站
- 安装:全程下一步就完了
- 检验安装:
cmd---> conda
(出现conda信息)或conda -V
- 配置:
更换国内源:在Anaconda Prompt(Miniconda3) 中使用conda config --set show_channel_urls yes
生成.condarc
文件
其路径:C:\Users\用户名\.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
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
- conda基本使用
- 查看环境
conda info -e
orconda env list
- conda创建,激活,注销,移除虚拟环境
- 查看环境
#(1)创建虚拟环境,同时指定python版本
conda create -n jupyter python=3.5
#(2)激活环境
conda activate jupyter
#(3) 注销or退出当前环境
conda deactivate jupyter
# (4)移除环境
conda remove -n jupyter--all
- 安装某环境下的包
conda list
conda install numpy #安装nunmpy,安装在默认的Python环境中
conda install -n py27numpy #在Python2编译环境中安装numpy包
- 创建jupyter
- 创建一个独立环境
conda create -n jupyter python=3.7
conda activate jupyter
- 在jupyter环境下使用pip或conda安装
安装jupyter:pip install jupyter
orconda install jupyter notebook
- jupyter配置
使用jupyter notebook --generate-config
命令生成配置文件jupyter_notebook_config.py
,其路径C:/Users/用户名/.jupyter/jupyter_notebook_config.py
- 安装jupyter插件
# step1: jupyter_contrib_nbextensions
# 用 pip 安装,二选一
# pip install jupyter_contrib_nbextensions
# 或用 conda 安装,二选一
conda install -c conda-forge jupyter_contrib_nbextensions
# 设置用户
# jupyter contrib nbextension install --user
step2: jupyter_nbextensions_configurator
# 用 pip 安装,二选一
# pip install jupyter_nbextensions_configurator
# 或用 conda 安装 ,二选一
conda install -c conda-forge jupyter_nbextensions_configurator
# 设置用户
jupyter contrib nbextension install --user
# 启用用户
jupyter nbextensions_configurator enable --user
出现问题:安装无法打开.ipynb文件,出现500
image.png
报错是因为nbconvert 和pandoc不兼容导致
解决办法:输入如下命令,安装升级nbconvert
pip install --upgrade --user nbconvert
https://blog.csdn.net/weixin_49779629/article/details/124064674
将conda中的环境添加到jupyter
python -m ipykernel install --user --name=环境名 --display-name "Python (环境名)"
(需ipykernel)