Linux下装anaconda/miniconda

一、anaconda:

在https://www.anaconda.com/products/individual#Downloads下载https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh ,
或者在终端wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh

下载完后,bash Anaconda3-5.3.1-Linux-x86_64.sh

mac:

brew install anaconda 
echo "export PATH=/opt/homebrew/anaconda3/bin:$PATH" >>~/.bash_profile
source ~/.bash_profile

conda create -n env0 python=3.10
source activate env0

brew install proxychains-ng
proxychains4
vim /opt/homebrew/etc/proxychains.conf
最后一行改为socks5 127.0.0.1 7890
proxychains4 conda install pytorch::pytorch torchvision torchaudio -c pytorch

二、miniconda (miniconda极其难用,用的时候老报错,anaconda就没那么多问题,不懂为什么那么多吹miniconda的)

在https://docs.conda.io/en/latest/miniconda.html下载https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh ,
或者在终端wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

下载完后,bash Miniconda3-latest-Linux-x86_64.sh

三、

source ~/.bashrc
conda --version # 查看conda版本
conda env list # 查看所有虚拟环境

conda create -n env_name python=3.7 # 创建虚拟环境
conda env remove -n env_name # 删除虚拟环境

conda activate env_name # 激活虚拟环境
conda deactivate # 退出虚拟环境

conda install package_name # 装包
conda uninstall package_name # 删包

四、.bashrc

channels:
  - defaults
show_channel_urls: true
ssl_verify: false
proxy_servers:
  http: http://127.0.0.1:7890
  https: http://127.0.0.1:7890

换镜像源:

nano ~/.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
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

然后运行conda clean -i清除索引缓存,保证用的是镜像站提供的索引。


有些包比较大要装很久,这样就不会中途connection failed:

conda config --set remote_read_timeout_secs 1000.0

参考:

https://zhuanlan.zhihu.com/p/123921247

https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

posted on 2021-03-22 11:48  HolaWorld  阅读(126)  评论(0编辑  收藏  举报

导航