美文网首页
python虚拟环境

python虚拟环境

作者: dinglangping | 来源:发表于2019-02-21 17:53 被阅读0次

Anaconda - python虚拟环境

官网:https://www.anaconda.com/download/#macos

1)conda list查看安装了哪些包。

2)conda env list或conda info -e查看当前存在哪些虚拟环境

3)conda update conda检查更新当前conda

1.创建Python虚拟环境 

conda create -n env_name python=2.7

1.1 .创建Python虚拟环境同时安装必要的包

conda create -n env_name numpy matplotlib python=2.7

conda create -n env_3.7 numpy matplotlib python=3.7

3.使用激活(或切换不同python版本)的虚拟环境。

Linux:  source activate your_env_name(虚拟环境名称)

4. python --version可以检查当前python的版本。

退出某个环境:

deactivate env_name

5.删除某个环境:

使用命令conda remove -n your_env_name(虚拟环境名称)--all,即可删除。

6.复制某个环境:

conda create new_env_name old_env_name

7.切换环境

source activate <env_name>

8.退出环境至root

source deactivate

10. 显示已创建环境

conda info --envs  或者conda info -e  或者conda env list

二、包管理

1.查看已安装的包:

conda list

2.查看指定环境下的包:

conda list -n xxx

3.查找包:

精确查找conda search --full-name xxx

模糊查找conda search xxx

4.更新包:

conda update xxx

更新所有包

conda update --all

5.安装包:

conda install xxx

pip install xxx

6.指定的安装环境:

conda install -n env_name xxx

7.安装anaconda发行版中所有的包:

conda install anaconda

8.卸载当前环境包:

conda remove xxx

卸载指定环境中的包

conda remove --name <env_name> <package_name>

三、管理conda

检查conda版本:

conda --version

升级当前版本的conda

conda update conda

四:设置国内镜像

如果需要安装很多packages,你会发现conda下载的速度经常很慢,因为Anaconda.org的服务器在国外。所幸的是,清华TUNA镜像源有Anaconda仓库的镜像,我们将其加入conda的配置即可:

1

2

3

4

5

6

#添加Anaconda的TUNA镜像

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

# TUNA的help中镜像地址加有引号,需要去掉

# 设置搜索时显示通道地址

conda config --set show_channel_urls yes

对虚拟环境中安装额外的包。

conda install -n your_env_name[package]

相关文章

网友评论

      本文标题:python虚拟环境

      本文链接:https://www.haomeiwen.com/subject/xyedyqtx.html