Anaconda使用虚拟环境

Anaconda使用虚拟环境

  • Anaconda
    • 查看已经存在的虚拟环境
    • 创建新的环境
    • 激活虚拟环境
    • 退出虚拟环境
    • 删除虚拟环境
    • 国内镜像源

Anaconda

Anaconda中的conda工具可以说是Python中较为方便的环境管理工具,下面介绍conda的相关操作

查看已经存在的虚拟环境

查看目前已经存在的虚拟环境:

conda env list

创建新的环境

创建新的虚拟环境:

conda create -n your_virtual_env_name python=3.7

激活虚拟环境

查看目前已经存在的虚拟环境:

# Windows
activate your_virtual_env_name
# Linux
source activate your_virtual_env_name

退出虚拟环境

# Windows
deactivate your_virtual_env_name
conda deactivate
# Linux
source deactivate your_virtual_env_name

删除虚拟环境

conda remove -n  your_virtual_env_name --all

国内镜像源

显示镜像源

conda config --show channels

添加镜像源

conda config --add channels [urls…]
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/conda-forge/
conda config --set show_channel_urls yes

使用pip命令也可以使用镜像源加速下载

pip install package_name -i [urls…]
# 例如安装pandas库
pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple

国内常用的镜像源:
阿里云:http://mirrors.aliyun.com/pypi/simple/
豆瓣:http://pypi.douban.com/simple/
清华大学 :https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学:http://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:https://pypi.hustunique.com/
山东理工大学:https://pypi.sdutlinux.org

你可能感兴趣的:(python,virtualenv)