环境配置流程细节摘要(持续更新)

1.pip conda换源

##conda
conda config --show-sources   #查看通道
conda info -e      #查看已经存在的conda环境


conda config --set remote_read_timeout_secs 1500.0 #设置download等待时间(防止HTTPERRORS)

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/ 
# 搜索时显示通道地址
conda config --set show_channel_urls yes

##pip 
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple


#conda换回默认源
conda config --remove-key channels

2.conda虚拟环境 + pytorch + jupyterlab一键安装

conda create -y -n my_env python=3.8 pytorch=1.6.0 jupyter_nb_conda_kernels
pip install torchvison==0.7.0

分开安装

conda create -n my_env python=3.8
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1
pip install jupyterlab
python -m ipykernel install --user --name my_env  #配置jupyterlab选择自己环境的kernel

3.pip install 设置等待时间

pip install -—default-timeout=1000 numpy

4.安装opencv

pip install opencv-python
pip install opencv-contrib-python

5.jupyter 选择kernel出现error:Failed to start the kernel Unhandled error

conda install pywin32
pip install jupyter_client --upgrade
pip install jupyter_core --upgrade

6.jupyterlab win10环境下修改启动默认目录

1.打开cmd,输入命令“jupyter notebook --generate-config”
2.执行命令后会显示新建立的Jupyter_notebook_config.py文件的路径。
3.通过路径,找到文件,用Notepad++或者IPython打开文件,对文件修改如下:

找到#c.NotebookApp.notebook_dir =’ ',删掉开头的“#”,在‘ ’中输入你要启动的目录路径。

7.安装graphviz

直接pip或者conda install会导入错误,解决方式是:

conda install graphviz
conda install python-graphviz

如果还有错误,找到Anaconda3中的my_env中的Library/bin,把改路径添加到用户变量里去。(针对win10)

8.jupyter添加/删除kernel

1、切换到要添加的虚拟环境,确认是否安装 ipykernel

python -m ipykernel --version

如果没有安装,则安装:

python -m pip install ipykernel

2、为 Jupyter notebook 添加内核

python -m ipykernel install --user --name=kernelname  --display-name 'py37'

3、查看 Jupyter notebook kernel

jupyter kernelspec list

4、删除 jupyter 内核

jupyter kernelspec remove kernelname

9.清除pip cache

rm -r ~/.cache/pip
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值