本文共 1852 字,大约阅读时间需要 6 分钟。
以前管理python的版本以及套件使用的是pyenv, 但是pyenv 使用起来还是比较麻烦。尤其是在服务器上,而且感觉支持社区会比较少。在同学的介绍下,了解并且使用conda来管理python 环境以及套件
相比anaconda, 肯定要用miniconda啦,没有必要下载个3-4g那么大的文件,以及提前下载那么多不一定用的库放到硬盘里啦
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
其他的另外去看吧
官网链接:sh Miniconda3-latest-Linux-x86_64.sh
这个时候 conda 一下,看到提示,就安装完成了:
看情况添加清华源,不然安装软件太慢了。。。就不太好
这里建议直接去清华源的网站看如何添加:
https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/其实就是在用户目录下的 .condarc 文件中下 写入以下内容:
channels: - defaultsshow_channel_urls: truechannel_alias: https://mirrors.tuna.tsinghua.edu.cn/anacondadefault_channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2custom_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 create -n 3.6.7 python=3.6.7
激活 conda activate env_name
退出虚拟环境 conda deactivate
移除指定包 conda remove PACKAGE_NAME
按照指定包 conda install PACKAGE_NAME
将工作环境导出为 .yml 文件 conda env export --name demo --file demo.yml
复制一个与 demo 完全相同的工作环境 conda env create --file demo.yml --name cloned-demo
当然我写完之后,我觉得pyenv更好用。为什么呢?
因为pyenv可以在不同的文件下指定不同的python版本
那么我多个项目切换的时候,我不需要自己手动的去切换python以及包的版本 这样更加舒服所以我这里附上pyenv 的安装以及使用链接:
转载地址:http://onywi.baihongyu.com/