目录
一、安装anaconda和使用
二、用conda创建python3.6环境
三、创建python虚拟环境
参考:Conda 安装使用图文详解(2022版)
文章摘要如下:
下载 (Linux 64位系统为例)
~$ wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Linux-x86_64.sh
安装
~$ bash Anaconda3-2021.11-Linux-x86_64.sh
检测
查看是否安装成功,在新开的终端中输入以下内容,如果安装没问题会显示conda版本号
~$ conda --version
如果出现conda not found 情况,打开新的终端测试就好。
配置镜像
1.先生成配置文件
~$ conda config --set show_channel_urls yes
2.打开配置文件
~$ gedit ~/.condarc
3.替换配置文件为以下内容
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 create -n py36 python==3.6
如果出现以下情况:
~$ conda create -n py3.6 python==3.6 Collecting package metadata (current_repodata.json): done Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. Collecting package metadata (repodata.json): done Solving environment: failed PackagesNotFoundError: The following packages are not available from current channels: - python==3.6 Current channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/linux-64 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/linux-64 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/noarch To search for alternate channels that may provide the conda package you're looking for, navigate to https://anaconda.org and use the search bar at the top of the page.
参考unbuntu、windows系统下解决安装了anaconda却无法创建python3.6环境的问题解决
文章摘要:
conda config --add channels Index of /anaconda/pkgs/free/linux-64/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
conda config --add channels Index of /anaconda/pkgs/main/linux-64/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
实际命令如下:
~$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/ ~$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
安装虚拟环境软件virtualenv
~$ pip install virtualenv
创建python虚拟环境
~$ virtualenv venv
退出虚拟环境:
~$ deactivate
进入虚拟环境
~$ cd /home/XX/venv/bin
~/venv/bin$
~/venv/bin$ bash activate
You must source this script: $ source activate
~/venv/bin$ source activate
(venv) (py36) XXXXXXXXXXX:~/venv/bin$
如上所是,说明已经进入了虚拟环境