博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
conda 安装以及使用小结
阅读量:3937 次
发布时间:2019-05-23

本文共 1852 字,大约阅读时间需要 6 分钟。

conda 安装以及使用小结

以前管理python的版本以及套件使用的是pyenv, 但是pyenv 使用起来还是比较麻烦。尤其是在服务器上,而且感觉支持社区会比较少。在同学的介绍下,了解并且使用conda来管理python 环境以及套件

安装conda

相比anaconda, 肯定要用miniconda啦,没有必要下载个3-4g那么大的文件,以及提前下载那么多不一定用的库放到硬盘里啦

  • linux 下面:
    wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh

其他的另外去看吧

官网链接:
sh Miniconda3-latest-Linux-x86_64.sh

  • 一路 enter
  • yes,同意协议。 记住这个时候安装的路径
  • yes,同意初始化,然后 source ~/.bashrc

这个时候 conda 一下,看到提示,就安装完成了:

在这里插入图片描述

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 config --remove-key channels

基本使用

有许多文档或者教程 可以参考这个:

  • 创建一个新的环境

    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/

你可能感兴趣的文章
软件评测和测试国家现行标准
查看>>
理解测试策略
查看>>
机器学习界大牛林达华推荐的书籍
查看>>
path变量备份
查看>>
Lesson2.2 & 2.3 Maya command reference & quick help
查看>>
lesson 2.4 - Converting MEL Commands to Python
查看>>
Lesson3.2 variables
查看>>
3.4.2 - Operators & 3.4.3 division and truncation
查看>>
3.7.1 - Strings
查看>>
3.7.4 - Indexing and Slicing Strings
查看>>
3.7.5 - Modifying Strings
查看>>
3.7.6 - String Methods
查看>>
3.8 - Using the Print Function
查看>>
3.9.1 - Lists in Python
查看>>
3.9.2 - Lists - Adding and Removing Objects
查看>>
3.9.3 - Sorting Lists
查看>>
3.10 - Maya Commands: ls
查看>>
3.11 - Dictionaries in Python
查看>>
3.12 - Tuples in Python
查看>>
4.4 - For Loops
查看>>